
| Contests | Virtual Contests | Problems | Submit | Runs Status | Rank List | Forum |
Since the dawn of civilization, mankind has been fascinated by strategy. Games requiring skills have been played by warriors throughout history to determine the fate of kingdoms, each player taking part in the age-old traditions of their culture. One of the oldest strategy game in existence is the game called GO. It came to existence over 3000 years ago in China where it was given the name, "Wei-chi". The popularity of GO quickly spread to other countries like Japan and Korea.
There are a limited number of rules in the game of Go. We list some primary rules here to help you solving the problem if you are not familiar with Go.
Rule I. The Go Board
Go is played on a square board consisting of any number of crossing lines. The usual board sizes are 9x9, 13x13 or 19x19 lines, the latter being the official tournament size.
To explain you the rules of the game we will use a 7x7 board since that will be more than sufficient for this purpose.
Usually you start the game with an empty board. Some dark spots in the board are used both for orientation and indication.
Rule II. Legal Moves

A Go move is played on the intersections of the lines. This is different from what you are used to from other games like chess and checkers. In the figure we show you the first four moves of an instruction game. The moves are numbered to indicate the order in which they were played.
That's right, in Go the black player moves first!
Rule III. Capturing Stones

During a Go game one or more stones can be captured by completely surrounding them, i.e. filling all empty points around them. We show three examples: the top figure a one stone capture, the middle figure a three stone capture, the bottom one capture with border.
After black has played his move at 1 he removes the captured white stones from the board leading to the right board positions.
Rule IV. The Aim Of The Game

The purpose of Go is to conquer a larger part of the board than your opponent. The conquered part exists of the stones placed on the board plus the stones which could be added safely, i.e. inside your own walls. The figure shows a final position. The score for this game would be: black has 11 stones on the board and could add 16 stones inside his own walls, white has 11 stones on the board and could add 11 stones inside his own walls, so the score is (11+16)-(11+11) is 5 points for black. Black won this game.
Given a board with stones on it, your program should determine what is the maximum number of white stones can be captured in one move. Note it's always black's turn.
There are multiple cases. The first line of each case contains a single integer N (3 ≤ N ≤ 500) indicates the size of board.
The next N lines with N characters each indicates the current status of the game. Here "." stands for a empty position, "W" for white, and "B" for black. There will be at least one empty position.
All games in the data are legal games, that is, no stone is being captured currently.
The input is terminated by N = 0.
For each case, you are required to output a single line contains the maximum number.
3 BBB WBW W.W 7 .....BW .W..... .BWB... .WBWWB. .WBWB.. ...B... ....... 0
4 3
Problem setter: Hill