
In the game "Hex," players compete on a rhombus-shaped board consisting of rows and hexagons per row, where is a positive integer not exceeding . The illustration shows the board configuration for N = 5. The game features two players: the first player uses white pieces, while the second player uses black pieces. During each turn, a player places one piece on any unoccupied hexagon. The objective for the white player is to create a continuous path of white pieces connecting the top and bottom edges of the board. Conversely, the black player's goal is to connect the left and right edges with a path of black pieces. Movement is allowed only through the sides of adjacent hexagons.
Your task is to write a program that determines if the white player has won in the current board position.
The first line contains the integer . The following lines each contain a string of characters. A character 'W' represents a hexagon occupied by a white piece, 'B' represents a black piece, and 'E' denotes an empty hexagon.
Output YES if the white player has won by forming a path connecting the top and bottom rows. Otherwise, output NO.
Example 1