#abc239f. [abc239_f]Construct Highway
[abc239_f]Construct Highway
Problem Statement
The Republic of Atcoder has towns numbered through , and highways numbered through .
Highway connects Town and Town bidirectionally.
King Takahashi is going to construct new highways so that the following two conditions are satisfied:
- One can travel between every pair of towns using some number of highways
- For each , exactly highways are directly connected to Town
Determine if there is such a way of construction. If it exists, print one.
Constraints
- If , then .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If there isn't a way of construction that satisfies the conditions, print -1
.
If there is, print lines. The -th line should contain the indices of the two towns connected by the -th highway to be constructed.
Sample Input 1
6 2
1 2 1 2 2 2
2 3
1 4
Sample Output 1
6 2
5 6
4 5
As in the Sample Output, the conditions can be satisfied by constructing highways connecting Towns and , Towns and , and Towns and , respectively.
Another example to satisfy the conditions is to construct highways connecting Towns and , Towns and , and Towns and , respectively.
Sample Input 2
5 1
1 1 1 1 4
2 3
Sample Output 2
-1
Sample Input 3
4 0
3 3 3 3
Sample Output 3
-1