def solve(S): w,g,r=0,0,0 for s in S[::-1]: if s=='R': r+=1 elif s=='G': g+=1 if g>r: return False elif g==0: return False elif w