#P1593F. Red-Black Number
Red-Black Number
No submission language available for this problem.
Description
It is given a non-negative integer , the decimal representation of which contains digits. You need to color each its digit in red or black, so that the number formed by the red digits is divisible by , and the number formed by the black digits is divisible by .
At least one digit must be colored in each of two colors. Consider, the count of digits colored in red is and the count of digits colored in black is . Among all possible colorings of the given number , you need to output any such that the value of is the minimum possible.
Note that the number and the numbers formed by digits of each color, may contain leading zeros.

The figure above shows an example of painting the number of digits for and . The red digits form the number , which is divisible by , and the black ones — , which is divisible by . Note that the absolute value of the difference between the counts of red and black digits is , it is impossible to achieve a smaller value.
The first line contains one integer () — the number of test cases. Then test cases follow.
Each test case consists of two lines. The first line contains three integers , , (, ). The second line contains a non-negative integer containing exactly digits and probably containing leading zeroes.
For each test case, output in a separate line:
- -1 if the desired coloring does not exist;
- a string of characters, each of them is a letter 'R' or 'B'. If the -th digit of the number is colored in red, then the -th character of the string must be the letter 'R', otherwise the letter 'B'.
The number formed by digits colored red should divisible by . The number formed by digits colored black should divisible by . The value should be minimal, where is the count of red digits, is the count of black digits. If there are many possible answers, print any of them.
Input
The first line contains one integer () — the number of test cases. Then test cases follow.
Each test case consists of two lines. The first line contains three integers , , (, ). The second line contains a non-negative integer containing exactly digits and probably containing leading zeroes.
Output
For each test case, output in a separate line:
- -1 if the desired coloring does not exist;
- a string of characters, each of them is a letter 'R' or 'B'. If the -th digit of the number is colored in red, then the -th character of the string must be the letter 'R', otherwise the letter 'B'.
The number formed by digits colored red should divisible by . The number formed by digits colored black should divisible by . The value should be minimal, where is the count of red digits, is the count of black digits. If there are many possible answers, print any of them.
Samples
Note
The first test case is considered in the statement.
In the second test case, there are no even digits, so it is impossible to form a number from its digits that is divisible by .
In the third test case, each coloring containing at least one red and one black digit is possible, so you can color digits in red and in black (, it is impossible to improve the result).
In the fourth test case, there is a single desired coloring.