Mr. Šikić, a chemistry teacher, is playing around with metal balls and copper wires. He joined together some pairs of balls with a wire so that all the balls are (directly or indirectly) linked to each other. He wants to teach his students about electric charge so he'll demonstrate it by charging the metal balls in a sequence.
Mr. Šikić can either charge each of the balls positively or negatively. When a ball is charged negatively, the electrons in all the wires connected to the ball are repulsed to the other ball connected to that wire. Conversely, if a ball is positively charged, the electrons from all the wires connected to that ball are pulled towards it. Charging the balls has the same effect on the wires irrespective of the wire's previous state.
At the beginning of the class, all the balls hold no charge and the electrons in all the wires are still. For every wire, Mr. Šikić has a specific direction of the electron flow in mind. Help him find a sequence of ball chargings that results in the desired electron flows.
Input Specification
The first line contains two integers and from the task statement.
The following lines contain integers and denoting that the balls and are connected by a wire and the electrons in the wire should be closer to , and not . There is at most one wire between a pair of balls. All the balls are directly or indirectly connected by wires.
Output Specification
If it is impossible to direct the flow of electrons according to Mr. Šikić's wishes, print -1
. Otherwise, print
, the required number of ball chargings. must be less than or equal to .
In the following lines, print integers and , the number of the ball Mr. Šikić should charge in step and whether it should be charged positively (denoted by ) or negatively (). If there are multiple solutions, print any one of them.
Constraints
Subtask | Points | Constraints |
---|---|---|
No additional constraints. |
Sample Input 1
3 3
1 2
2 3
1 3
Sample Output 1
3
2 1
3 0
1 1
Explanation for Sample Output 1
First, we give ball a positive charge. The electrons on wires between balls and , and balls and are now closer to ball . The wire connecting balls and remains neutral.
Now, we give ball a negative change. The arrangement of electrons between wires and remains unchanged, while the electrons on the wire between and are closer to ball .
Finally, we give ball a positive charge. The wire between and remains unchanged, but on the wire between balls and , electrons are now closer to ball and the desired arrangement is achieved.
Sample Input 2
4 3
1 2
3 2
2 4
Sample Output 2
4
2 1
4 0
3 1
1 1
Sample Input 3
5 10
2 4
3 4
1 4
4 5
3 2
2 1
5 2
1 3
5 3
1 5
Sample Output 3
-1
Comments