Foreign Football
시간 제한5초메모리 제한1024 MB
모든 순서쌍에 대한 s_i+s_j 연결 문자열이 주어질 때, n개의 비어 있지 않은 이름을 복원하거나 해가 없거나 여러 개임을 판정한다.
문제
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 teams in total, named . You are given the concatenation for every ordered pair . Find the teams names . Team names must be nonempty, but they do not need to be distinct.
입력
The first line of input contains the integer ().
The following lines each contain strings, the table of concatenated team names. The :th string on the :th of these lines will contain the string if , and "*" if . The concatenated team names will consist of lower case characters a-z.
The total number of characters in concatenated team names is at most .
출력
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 lines containing .