PivotOJ

Foreign Football

시간 제한: 5000ms메모리 제한: 1024MB출처: NCPC 2022BOJ 26029

문제

You are on vacation in a foreign country. This country has a local football league, and you don't know any of the team names. However, you have found a table of all the results from this season, and next to every match is the concatenated names of the two teams that played.

There are nn teams in total, named s1,s2,,sns_1, s_2, \cdots, s_n. You are given the concatenation si+sjs_i+s_j for every ordered pair iji \neq j. Find the teams names s1,s2,,sns_1, s_2, \cdots, s_n. Team names must be nonempty, but they do not need to be distinct.

입력

The first line of input contains the integer nn (2n5002 \leq n \leq 500).

The following nn lines each contain nn strings, the table of concatenated team names. The jj:th string on the ii:th of these lines will contain the string si+sjs_i + s_j if iji \neq j, and "*" if i=ji = j. The concatenated team names will consist of lower case characters a-z.

The total number of characters in concatenated team names is at most 10610^6.

출력

If there is no solution, print "NONE".

If there is more than one solution, print "MANY".

If there is one unique solution, print "UNIQUE", followed by nn lines containing s1,s2,,sns_1, s_2, \cdots, s_n.

예제

예제 1

입력
3
* difaik difhammarby
aikdif * aikhammarby
hammarbydif hammarbyaik *
출력
UNIQUE
dif
aik
hammarby

예제 2

입력
2
* aaaa
aaaa *
출력
MANY

예제 3

입력
3
* a ab
a * b
ba b *
출력
NONE

예제 4

입력
2
* zz
zz *
출력
UNIQUE
z
z
코드를 제출하려면 로그인하세요.