Chips Challenge#2284

Chips Challenge

30 seconds
256 megabytes
Easy

A prominent microprocessor company has enlisted your help to lay out some interchangeable components (widgets) on some of their computer chips. Each chip’s design is an N \times N square of slots. One slot can hold a single component, and you are to try to fit in as many widgets as possible.

Modern processor designs are complex, of course. Unfortunately, you have several restrictions:

A specification for a chip is lines of characters, where '.' indicates an open slot, '/' indicates a disabled slot, and 'C' indicates a slot already occupied by a component. For example:

CC/.. ./.// ..C.C /.C.. /./C/

If no more than of the components may be in any one row or column, the maximum number of widgets that can be added to this 5 \times 5 chip is . A possible arrangement is below, where 'W' indicates a widget added in an open slot.

CC/W. W/W// W.C.C /.CWW /W/C/

Input

The input consists of several test cases. Each case starts with a line containing three integers: the size of the chip (1 \leq N \leq 10), and and (1 \leq B \leq 1000, 0 \leq A \leq B) as described above. Each of the following lines contains characters describing the slots, one of '.', '/' or 'C', as described above.

The last test case is followed by a line containing three zeros.

Output

For each test case, display a single line beginning with the case number. If there is a solution, display the maximum number of widgets that can be added to the chip. Display impossible if there is no solution.

Follow the format of the sample output.

Examples

Example 1

Loading
Loading