Welcome to ZOJ
Information
Problems
Runs
Statistics
Ranklist
Clarification
120 - ZOJ Monthly, September 2012 - C
Matrix Transformer

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Alice and Bob meet again. This time they play a game named MATRIX TRANSFORMER.

They got an n * n board. Every grid has two positions, UP and DOWN. In this game you can push some amazing buttons to exchange any two rows or any two columns. Alice will win if she got the grids in the main diagonal line all UP.

But Alice finds that for some board, no matter how many times she tries, she cannot get the grids in the main diagonal line all UP. Now she asks you for help, tell her if she can win this board or not.

Input

There are several test cases.
For each test case:
The 1st line contains 1 integer n, indicating the size of the board. (1 ≤ n ≤ 200)
The next n lines, each contains n characters. 'U' indicates the position UP, and 'D' indicates the position DOWN.
There is no separation line between any two test cases.

Output

For each test case, you should print one line. You should print 'YES' if Alice can win, print 'NO' if not.

Sample Input

3
DUD
UDD
DDU
3
DUD
DUD
UDD

Sample Output

YES
NO

Author: LI, Tierui
Submit    Status