CSES - HIIT Open 2018 - Knobs
  • Time limit: 2.00 s
  • Memory limit: 512 MB

You have a graph with nn nodes and mm edges. Each node has a knob that you can turn clockwise or counterclockwise. Each knob can be in one of three positions: 0°, 120°, 240°. Initially, knob ii is in position aia_i.

For each knob ii you also know its final position, bib_i. You will need to find a way to turn knobs so that:

  • in each step you turn only one knob (from one position to another position)
  • two knobs that are connected by an edge are never in the same position
  • after you are done, each knob is in its final position

Note that you can turn the same knob many times, to any of the positions.

Input

The first input line has two integers nn and mm: the number of knobs and edges.

Then there are nn lines, each with two numbers aia_i and bib_i. These indicate the current position aia_i and the final position bib_i of knob ii.

Finally, there are mm lines, each with two numbers ii and jj. This indicates that there is an edge between nodes ii and jj; here 1i<jn1 \le i < j \le n.

The input configuration and the final configuration are valid: if there is an edge between knobs ii and jj, then aiaja_i \ne a_j and bibjb_i \ne b_j.

All inputs are such that if a solution exists, there is at least one solution with at most 10510^5 steps.

Output

If there is a way to turn knobs so that you can reach the final configuration, print a sequence that shows how to do it. First print one line with a number ss (at most 51055 \cdot 10^5): the number of steps. Then print ss lines, each with a pair of numbers, xkx_k and pkp_k: in step kk you turn knob xkx_k to position pkp_k. Here 1xkn1 \le x_k \le n and pkp_k is 0, 120, or 240.

If there is no way to solve the problem, print only one line with value 1-1.

Constraints

  • 1n200001 \le n \le 20000
  • 1m200001 \le m \le 20000

Example

Input:

4 4
0 0
120 240
240 120
120 240
1 2
2 3
3 4
1 4

Output:

4
3 0
4 240
2 240
3 120

The following illustration shows the solution with four steps. Here 0° points up, 120° down right and 240° down left.