{"raw_statement":[{"iden":"problem statement","content":"We have a grid with $N$ horizontal rows and $N$ vertical columns.  \nLet $(i, j)$ denote the square at the $i$\\-th row from the top and $j$\\-th column from the left. A character $c_{i,j}$ describes the color of $(i, j)$.  \n`B` means the square is painted black; `W` means the square is painted white; `?` means the square is not yet painted.\nTakahashi will complete the black-and-white grid by painting each unpainted square black or white.  \nLet the **zebraness** of the grid be the number of pairs of a black square and a white square sharing a side.  \nFind the maximum possible zebraness of the grid that Takahashi can achieve."},{"iden":"constraints","content":"*   $1 ≤ N ≤ 100$\n*   $c_{i, j}$ is `B`, `W`, or `?`."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$c_{1,1} \\dots c_{1,N}$\n$\\hspace{20pt}\\vdots$\n$c_{N,1} \\dots c_{N,N}$"},{"iden":"sample input 1","content":"2\nBB\nBW"},{"iden":"sample output 1","content":"2\n\nWe have two pairs of a black square and a white square sharing a side: $(1, 2), (2, 2)$ and $(2, 1), (2, 2)$, so the zebraness of this grid is $2$."},{"iden":"sample input 2","content":"3\nBBB\nBBB\nW?W"},{"iden":"sample output 2","content":"4\n\nPainting $(3, 2)$ white makes the zebraness $3$, and painting it black makes the zebraness $4$."},{"iden":"sample input 3","content":"5\n?????\n?????\n?????\n?????\n?????"},{"iden":"sample output 3","content":"40"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}