This page is still under construction.

Parts of this page are still being built. What you see may change.

Circular Game

Time limit1sMemory limit128 MB

Summary
On a circular board, white and black pieces slide over empty runs; decide with optimal play which side wins or whether play can go on forever.
Level

Medium7 of 10

Topics
Game theory, Array, Implementation, Sorting
Solved
No attempts yet

Problem

The board of the circular game is a ring of mm fields numbered from 1 to mm. It carries bb white pieces and cc black pieces, at most one piece on a field. The white player and the black player move alternately, and white starts.

A move takes one piece of the player's own colour forward or backward across any number of free fields. Every field the piece passes must be empty. On the board drawn below, white can move the piece on field 3 to field 4, or the piece on field 8 to field 7, 9 or 1.

A player with no legal move on his turn loses. Both players play optimally. Decide who wins. The game can also go on forever, with neither player winning.

Input

The first line contains the number of boards tt. Each board is then described by three lines.

The first line of a board holds its length mm, the number of white pieces bb and the number of black pieces cc, separated by single spaces (1≤m≤1091 \le m \le 10^9, 1≤b1 \le b, 1≤c1 \le c).

The second line holds the bb fields taken by white pieces in increasing order, and the third line holds the cc fields taken by black pieces in increasing order. Every field number is between 1 and mm.

The pieces on all boards add up to at most 10610^6.

Output

Print exactly tt lines, one answer per board, in the order the boards are given. Each answer is a single character: B if the white player wins, C if the black player wins, R if the game never ends.

Examples1

  1. Example 1

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