for _ in[0]*input(): s=list(raw_input()) while"W"in s: w=s.index("W") if "G"not in s: break g=s.index("G") if "R"not in s: break r=s.index("R") if w