Make it Colorful
Easy Accuracy: 20.64% Submissions: 160 Points: 2

In a party, there are 4 dress codes i.e. one can either wear Red(R) or Blue(B) or Green(G) or Yellow(Y). Photographer needs the most colorful pic he can, so he arranges people in a specific order like RGBYRGBY, RYBGRY, RYBGR, RGBYRGB but no order like GGBRGBR, BGYBGY, GBGGBYR. Using the given information you have tell the no. of persons of a particular color required in the order if there is a place for a particular color to have the colorful pic.

Input :
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. First line contains a string representing the 'order' where an '!' denotes a missing character. You may assume that no Input like GBYR!Y!!!! or YG!!RB!G will be given.

Output :
For each test case in a new line print the string RxByYmGn where x, y, m, n represent the count of the missing colors ie red, blue, yellow, green in the string which satisfies the order.

Constraints:
1<=T<=17
1<=Length of string<=1000

 

Example :
Input:

3
YRGBYRGB
!!!!RYGB
!!!!!BGYR

Output:
R0B0Y0G0
R1B1Y1G1
R2B1Y1G1

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.