are given a non-negative number x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, with the goal that the number shaped by the red digits is detachable by A, and the number framed by the dark digits is distinct by B.
Do it in python.
There are given a non-negative number x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, with the goal that the number shaped by the red digits is detachable by A, and the number framed by the dark digits is distinct by B.
Somewhere around one digit should be shaded in every one of two tones. Consider, the include of digits shaded in red is r and the include of digits hued in dark is b. Among all potential colorings of the given number x, you need to yield any to such an extent that the worth of |r−b| is the base conceivable.
Note that the number x and the numbers shaped by digits of each tone, may contain driving zeros. instance of painting the number x=02165 of n=5 digits for A=3 and B=13. The red digits structure the number 015, which is detachable by 3, and the dark ones — 26, which is distinguishable by 13. Note that the outright worth of the distinction between the counts of red and dark digits is 1, it is difficult to accomplish a more modest worth.
Info
The main line contains one number t (1≤t≤10) — the quantity of experiments. Then, at that point, t experiments follow.
Each experiment comprises of two lines. The main line contains three numbers n, A, B (2≤n≤40, 1≤A,B≤40). The subsequent line contains a non-negative number x containing precisely n digits and presumably containing driving zeroes.
Yield: For each experiment, yield in a different line: - 1 if the ideal shading doesn't exist;
a string s of n characters, every one of them is a letter 'R' or 'B'. On the off chance that the I-th digit of the number x is hued in red, then, at that point, the I-th character of the string s should be the letter 'R', in any case the letter 'B'
Step by step
Solved in 4 steps with 1 images