Score : $500$ points
The Republic of Atcoder has $N$ towns numbered $1$ through $N$, and $M$ highways numbered $1$ through $M$.
Highway $i$ connects Town $A_i$ and Town $B_i$ bidirectionally.
King Takahashi is going to construct $(N-M-1)$ new highways so that the following two conditions are satisfied:
Determine if there is such a way of construction. If it exists, print one.
Input is given from Standard Input in the following format:
$N$ $M$ $D_1$ $\ldots$ $D_N$ $A_1$ $B_1$ $\vdots$ $A_M$ $B_M$
If there isn't a way of construction that satisfies the conditions, print -1
.
If there is, print $(N-M-1)$ lines. The $i$-th line should contain the indices of the two towns connected by the $i$-th highway to be constructed.
6 2 1 2 1 2 2 2 2 3 1 4
6 2 5 6 4 5
As 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.
Another example to satisfy the conditions is to construct highways connecting Towns $6$ and $4$, Towns $5$ and $6$, and Towns $2$ and $5$, respectively.
5 1 1 1 1 1 4 2 3
-1
4 0 3 3 3 3
-1