
128  The 2013 ACMICPC Asia Changsha Regional Contest  G
Let there be a simple graph with N vertices but we just know the degree of each vertex. Is it possible to reconstruct the graph only by these information? A simple graph is an undirected graph that has no loops (edges connected at both ends to the same vertex) and no more than one edge between any two different vertices. The degree of a vertex is the number of edges that connect to it. InputThere are multiple cases. Each case contains two lines. The first line contains one integer N (2 ≤ N ≤ 100), the number of vertices in the graph. The second line conrains N integers in which the i_{th} item is the degree of i_{th} vertex and each degree is between 0 and N1(inclusive).OutputIf the graph can be uniquely determined by the vertex degree information, output "UNIQUE" in the first line. Then output the graph. If there are two or more different graphs can induce the same degree for all vertices, output "MULTIPLE" in the first line. Then output two different graphs in the following lines to proof. If the vertex degree sequence cannot deduced any graph, just output "IMPOSSIBLE". The output format of graph is as follows: N E u_{1} u_{2} ... u_{E} v_{1} v_{2} ... v_{E}Where N is the number of vertices and E is the number of edges, and {u_{i},v_{i}} is the i_{th} edge the the graph. The order of edges and the order of vertices in the edge representation is not important since we would use special judge to verify your answer. The number of each vertex is labeled from 1 to N. See sample output for more detail. Sample Input1 0 6 5 5 5 4 4 3 6 5 4 4 4 4 3 6 3 4 3 1 2 0 Sample OutputUNIQUE 1 0 UNIQUE 6 13 3 3 3 3 3 2 2 2 2 1 1 1 5 2 1 5 4 6 1 5 4 6 5 4 6 4 MULTIPLE 6 12 1 1 1 1 1 5 5 5 6 6 2 2 5 4 3 2 6 4 3 2 4 3 4 3 6 12 1 1 1 1 1 5 5 5 6 6 3 3 5 4 3 2 6 4 3 2 4 2 4 2 IMPOSSIBLE Author: WANG, Yelei 