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.

1<=Length of string<=1000


Example :



to report an issue on this page.


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


All Submissions

My Submissions:

Login to access your submissions.