A Latin Square is an ~N~-by-~N~ array filled with ~N~ 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 ~N~-by-~N~ array, determine if it is a Latin Square, and if so, if it is in reduced form.
~2 \le N \le 36~
The first line contains a single positive integer ~N~.
Each of the next ~N~ lines contains ~N~ digits in base ~N~. 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 ~N~.
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.
3 012 120 201
4 3210 0123 2301 1032
11 0123458372A A9287346283 0285475A834 84738299A02 1947584037A 65848430002 038955873A8 947530200A8 93484721084 95539A92828 04553883568