cho.sh
Notes
Loading...

Sejun and Sebi's War

Time limit

2s

Memory limit

128 MB

Problem

Sejun and Sebi have each raised an army in an online game. Sejun has N soldiers, and Sebi has M soldiers. They are about to go to war.

The war consists of repeated battles. In each battle, one soldier with the smallest strength among all living soldiers dies. If several weakest soldiers all belong to the same side, one of them is chosen arbitrarily and dies. If the weakest strength appears on both sides, one of Sebi's weakest soldiers dies.

The war ends when only one soldier remains. Determine and print the winner of the war.

Input

The first line contains the number of test cases T. T is at most 100.

Each test case consists of three lines.

  • The first line contains N, the number of Sejun's soldiers, and M, the number of Sebi's soldiers.
  • The second line contains the strengths of Sejun's soldiers.
  • The third line contains the strengths of Sebi's soldiers.

Each strength is an integer, and a larger value means a stronger soldier. There may be blank lines between test cases.

Output

For each test case, print one winner per line. Print S if Sejun wins, B if Sebi wins, and C if neither side wins.

Constraints

  • 1 <= N, M <= 1,000,000
  • Every soldier's strength is a positive integer not greater than 300,000,000.