Hogwarts staircases

No attempts yetTime limit1sMemory limit256 MB

Problem

The new semester at Hogwarts has just started, but the staircases are not cooperating with the school administrators. Hogwarts has a single room of movable staircases connecting the NN floors. There are MM staircases in total. No two staircases connect the same pair of floors, and a staircase does not connect a floor to itself.

The only way to manipulate the staircases is by pressing red and green buttons on each floor. The floors are labeled 00 to N1N-1.

Pressing the red button on floor ii (0iN10 \le i \le N-1) has the following effect. Any staircase that is not currently connected to floor ii does not move. If a staircase connects floors ii and jj (jij \neq i), it then connects floors ii and j+1modNj+1 \bmod N, unless j+1modN=ij+1 \bmod N = i, in which case it connects floors ii and j+2modNj+2 \bmod N, which equals i+1modNi+1 \bmod N.

Pressing the green button is the inverse of pressing the red button on the same floor. Equivalently, it is the same as pressing the red button N2N-2 times.

While left alone, the staircases became jumbled. The administrators have a desired placement. You are a low-ranking house elf, and you must realize that plan.

Print a shortest sequence of button presses that changes the current layout into the desired layout. If several shortest sequences exist, print the lexicographically smallest one. Each press is the string R i or G i. The letter R comes before G, and a smaller floor index comes before a larger one.

Input

There is a single test case. The first line contains NN and MM (3N503 \le N \le 50, 0MN(N1)/20 \le M \le N(N-1)/2).

Then follow MM lines of integers ii, jj (0i,jN10 \le i, j \le N-1), the current staircases. Each line means a staircase connects floors ii and jj. Then follow another MM lines of integers ii, jj, the desired staircases.

Neither layout contains two staircases between the same pair of floors. Some pairs may appear in both layouts. A sequence from the current layout to the desired layout always exists.

Output

On the first line print a single integer QQ (0Q2500000 \le Q \le 250000), the length of the sequence. Then print QQ lines, each R i or G i for some ii (0iN10 \le i \le N-1), meaning the red or green button on floor ii is pressed.

The sequence must be the unique shortest sequence under the lexicographic rule above.