A Latin Square is an -by- array filled with different digits, each digit occurring exactly once in each row and exactly once in each column.
A Latin Square is in reduced form if the top row and leftmost column are sorted in increasing order.
Given an -by- array, determine if it is a Latin Square, and if so, if it is in reduced form.
Constraints
Input Specification
The first line contains a single positive integer .
Each of the next lines contains digits in base . The digits 0 through 9 will be represented as is, and the uppercase letters A through Z represent the digits 10 through 35. The digits are guaranteed to be valid in base .
Output Specification
If the array is not a Latin Square, print No
on a single line.
If the array is a Latin Square, but not in reduced form, print Latin
on a single line.
If the array is a Latin Square in reduced form, print Reduced
on a single line.
Sample Input 1
3
012
120
201
Sample Output 1
Reduced
Sample Input 2
4
3210
0123
2301
1032
Sample Output 2
Latin
Sample Input 3
11
0123458372A
A9287346283
0285475A834
84738299A02
1947584037A
65848430002
038955873A8
947530200A8
93484721084
95539A92828
04553883568
Sample Output 3
No
Comments
Since the original data were weak, an additional test case was added, partials were disabled, and all submissions were rejudged.