Peg games may be played on a variety of boards, but the goal is always the same, to end the game with as few pegs on the board as possible. This is accomplished by making a sequence of moves, where one peg `jumps' an adjacent peg to the empty space on the opposite side. Pegs which are jumped by other pegs are immediately removed.
Given the starting configuration of a peg board, your program should determine the number of pegs that will remain on the board if the player makes the best possible sequence of moves.
One standard peg board is a 5 x 5
Input to this problem will begin with a line containing a single integer
n
For each board in the input, print the message `The best case ends with
Y
#...#
#.o.#
#...#
.....
..o..
.....
.....
oo.o.
...o.
.....
.....
.....
#...#
#...#
#...#
Figure A
Figure B
Figure C
Note that not all of the peg boards given to you will be the same shape!
They will all be 5 x 5
Input
Output
Sample
Input
3
#.o.#
..o..
oo.o.
.....
#...#
#...#
o.o.o
....o
...o.
#o..#
#..##
.o..#
ooo.o
.o.o.
#..o#
Sample
Output
The best case ends with 1 pegs.
The best case ends with 4 pegs.
The best case ends with 2 pegs.