#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

Rar the Cat is visiting the arcade with his friends. He has came across a very interesting arcade machine, named Bishi Bashi. The machine contains a wide variety of competitive minigames, based on bashing various buttons.

The machine in the arcade caters for up to 3 players. However, Rar the Cat is only here with Jacq the Dinosaur. Nevertheless, they decide to give the game a try.

One of the minigames involves bashing buttons to kill a particular monster. The monster will be killed after Rar the Cat and Jacq the Dinosaur presses the buttons *X* times.

While playing this particular minigame, Rar the Cat manages to press his button once every *R* milliseconds while Jacq the Dinosaur manages to press her button once every *J* milliseconds. Both Rar and Jacq will press their buttons once at the 0^{th} millisecond. Subsequently, Rar the Cat will press once at every multiple of *R* milliseconds and Jacq the Dinosaur will press once at every multiple of *J* milliseconds.

As they are too engrossed in their button bashing, Rar the Cat and Jacq the Dinosaur did not notice which one of them delivered the 'final blow' to the monster. The 'final blow' is the last press of the button which manages to kill the monster. If both Rar and Jacq presses the button at the exact same moment and the monster dies, both of them are considered to have killed the monster.

They have played a total of *N* rounds of the above minigame and want you to figure out who delivered the 'final blow' for each of the rounds. For each round, there will be a different value of *R*, *J* and *X*, with the *i ^{th}* round having

*R*,

_{i}*J*and

_{i}*X*respectively.

_{i}## Limits

For all testcases, 0 < R_{i}, J_{i}, X_{i} ≤ 10^{9} unless otherwise indicated in the subtasks.

Subtask 1 (2%): 1 ≤ N ≤ 20. However, all R_{i} = J_{i}.

Subtask 2 (29%): 1 ≤ N ≤ 20, 0 < R_{i}, J_{i}, X_{i} ≤ 10^{3}.

Subtask 3 (18%): 1 ≤ N ≤ 20, 0 < *X _{i}* ≤ 10

^{6}.

Subtask 4 (20%): 1 ≤ N ≤ 500000. However, all of the *N* rounds will have the same value of *R* and *J*. In other words, all R_{i} = R_{1} and all J_{i} = J_{1} for all i > 1.

Subtask 5 (31%): 1 ≤ N ≤ 500000.

Subtask 6 (0%): Sample Testcases.

## Input

The first line of input will contain one integer, *N*.

The next *N* lines of input will contain 3 integers each. The *i ^{th}* line will contain

*R*,

_{i}*J*followed by

_{i}*X*.

_{i}## Output

For each of the *N* rounds, output "R" if Rar the Cat delivered the 'final blow' and output "J" if Jacq the Dinosaur delivered the 'final blow'. If the 'final blow' was delivered by the both of them, output "RJ". You are to output the result for each round on a different line, one on each line.

## Sample Testcase 1

### Input

10 2 4 1 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 4 7 2 4 8 2 4 9 2 4 10

### Output

RJ RJ R RJ RJ R RJ RJ R RJ

### Explanation

At time 0, Rar and Jacq would have pressed the button simultaneously. Hence, any monster whose *X = 1 or 2* will be killed by both of them at the same time, at time 0.

At time 2, Rar will press the button once. Any monster whose *X = 3* will be killed by him.

At time 4, Rar and Jacq would have pressed at the same time. Monster with *X = 4 or 5* are killed by both of them.

At time 6, Rar will press the button once, alone. Any monster whose *X = 6* will be killed only by him.

At time 8, Rar and Jacq presses the button together, killing any monster whose *X = 7 or 8*.

At time 10, Rar will press the button alone, killing *X = 9*.

At time 12, Rar and Jacq will press the buttons together, killing *X = 10 or 11*.

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 2 | 21 | 2s | 64MB | Minimum |

2 | 29 | 26 | 2s | 64MB | Minimum |

3 | 18 | 61 | 2s | 64MB | Minimum |

4 | 20 | 15 | 2s | 64MB | Minimum |

5 | 31 | 109 | 2s | 64MB | Minimum |

6 | 0 | 1 | 2s | 64MB | Minimum |

### Judge Compile Command

g++ ans.cpp -o bishibashi -Wall -static -O2 -lm -m64 -s -w -std=gnu++14 -fmax-errors=512