{"raw_statement":[{"iden":"problem statement","content":"The Republic of Atcoder has $N$ towns numbered $1$ through $N$, and $M$ highways numbered $1$ through $M$.  \nHighway $i$ connects Town $A_i$ and Town $B_i$ bidirectionally.\nKing Takahashi is going to construct $(N-M-1)$ new highways so that the following two conditions are satisfied:\n\n*   One can travel between every pair of towns using some number of highways\n*   For each $i=1,\\ldots,N$, exactly $D_i$ highways are directly connected to Town $i$\n\nDetermine if there is such a way of construction. If it exists, print one."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2\\times 10^5$\n*   $0 \\leq M \\lt N-1$\n*   $1 \\leq D_i \\leq N-1$\n*   $1\\leq A_i \\lt B_i \\leq N$\n*   If $i\\neq j$, then $(A_i, B_i) \\neq (A_j,B_j)$.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$D_1$ $\\ldots$ $D_N$\n$A_1$ $B_1$\n$\\vdots$\n$A_M$ $B_M$"},{"iden":"sample input 1","content":"6 2\n1 2 1 2 2 2\n2 3\n1 4"},{"iden":"sample output 1","content":"6 2\n5 6\n4 5\n\nAs in the Sample Output, the conditions can be satisfied by constructing highways connecting Towns $6$ and $2$, Towns $5$ and $6$, and Towns $4$ and $5$, respectively.\nAnother example to satisfy the conditions is to construct highways connecting Towns $6$ and $4$, Towns $5$ and $6$, and Towns $2$ and $5$, respectively."},{"iden":"sample input 2","content":"5 1\n1 1 1 1 4\n2 3"},{"iden":"sample output 2","content":"\\-1"},{"iden":"sample input 3","content":"4 0\n3 3 3 3"},{"iden":"sample output 3","content":"\\-1"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}