#P6814. [PA 2009] Circular Game

[PA 2009] Circular Game

Description

There is a circular board of size mm, with aa white pieces and bb black pieces on it.

White moves first. In one move, a piece may move to a position such that there are no pieces on any position in between.

For example, in the figure below, the piece at position 88 can move to any of positions 1,7,91, 7, 9.

Input Format

The first line contains an integer tt, the number of test cases.

For each test case, the first line contains three integers mm, aa, and bb, representing the board length, the number of white pieces, and the number of black pieces.

The second line of each test case contains a strictly increasing sequence of integers, representing the positions of the white pieces.

The third line of each test case contains a strictly increasing sequence of integers, representing the positions of the black pieces.

Output Format

For each test case, output a single character: BB, CC, or RR.

Output BB if White wins, output CC if Black wins, and output RR if the game never ends.

3
9 2 3
3 8
2 5 6
6 2 2
5 6
2 4
7 1 1
3
4
C
B
R

Hint

Constraints: 1m1091 \leq m \leq 10^9, 1a+b1061 \leq \sum a + b \leq 10^6.

Translated by ChatGPT 5