Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 200200 points
Problem Statement
NN pla
yers played a round-robin tournament.
You are given an NN-by-NN table AA containing the results of the matches. Let A_{i,j}Ai,j denote the element at the ii-th row and jj-th column of AA.
A_{i,j}Ai,j is - if i=ji=j, and W, L, or D otherwise.
A_{i,j}Ai,j is W if Player ii beat Player jj, L if Player ii lost to Player jj, and D if Player ii drew with Player jj.
Determine whether the given table is contradictory.
The table is said to be contradictory when some of the following holds:
-
There is a pair (i,j)(i,j) such that Player ii beat Player jj, but Player jj did not lose to Player ii;
-
There is a pair (i,j)(i,j) such that Player ii lost to Player jj, but Player jj did not beat Player ii;
-
There is a pair (i,j)(i,j) such that Player ii drew with Player jj, but Player jj did not draw with Player ii.
Constraints
-
2 \leq N \leq 10002≤N≤1000
-
A_{i,i}Ai,i is -.
-
A_{i,j}Ai,j is W, L, or D, for i\neq ji=j.
Input
Input is given from Standard Input in the following format:
NNA_{1,1}A_{1,2}\ldots A_{1,N}A1,1A1,2…A1,NA_{2,1}A_{2,2}\ldots A_{2,N}A2,1A2,2…A2,N\vdots⋮A_{N,1}A_{N,2}\ldots A_{N,N}AN,1AN,2…AN,N
Output
If the given table is not contradictory, print correct; if it is contradictory, print incorrect.