QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 10

#11182. Circular Game [A]

Statistics

In the "circular game" the board consists of $ m $ fields arranged on a circle and numbered from 1 to $ m $. On the board there are $ b $ white and $ c $ black pieces, at most one on each field. Two players are playing the game, the white player and the black player. Starting from the white player, the players perform their moves on the board alternately. A move consists of moving a piece of the player's colour any number of free fields forward or backward. For instance, for the board depicted below, the white player can move the piece from field 3 to field 4 or the piece from field 8 to any of the fields 7, 9 and 1.

problem_11182_1.gif

If a player can perform no moves in his turn, he loses. Knowing that both players play optimally, check who wins the game. It can happen that none of the players wins (the game never ends).

Input Format

The first line of the standard input contains one integer $ t $ representing the number of boards to be considered. The following lines contain descriptions of respective boards, each of which consists of three lines. In the first line there are three integers $ m $, $ b $ and $ c $ ($1 ≤ m ≤ 10^{9}$, $1 ≤ b, c $) separated by single spaces and denoting the length of the board, the number of white pieces and the number of black pieces. In the second line there is an increasing sequence of $ b $ integers (in the range $1, \ldots, m $) representing the positions of white pieces. In the third line there is an increasing sequence of $ c $ integers (in the range $1, \ldots, m $) representing the positions of black pieces. The total number of pieces in all boards does not exceed $10^{6}$.

Output Format

Exactly $ t $ lines with answers for consecutive boards should be written to the standard output. The answer is always a single character: B, C, or R, depending on whether the white player wins (B), the black player wins (C) or the game never ends (R).

Example

Input

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

Output

C
B
R
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.