This Ain't Your Grandpa's Checkerboard

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

You are given an nn-by-nn grid where each square is colored either black or white. A grid is correct if all of the following conditions are satisfied:

  • Every row has the same number of black squares as it has white squares.
  • Every column has the same number of black squares as it has white squares.
  • No row or column has 33 or more consecutive squares of the same color.

Given a grid, determine whether it is correct.

입력

The first line contains an integer nn (2n242\le n\le 24; nn is even). Each of the next nn lines contains a string of length nn consisting solely of the characters 'B' and 'W', representing the colors of the grid squares.

출력

If the grid is correct, print the number 11 on a single line. Otherwise, print the number 00 on a single line.