T = int(input()) tt=[] for _ in range(T): tt.append(input()) for t in tt: t = list(t) if len(t)<3: print("impossible") continue countW=0 countG=0 countR=0 Flag=True FlagW=False for i in t: if i=="G": countG+=1 elif i=="R": countR+=1 FlagW=True else: countW+=1 FlagW=False if countG-countR<0: Flag=False continue t.reverse() countG2=0 for i in t: if i=="G": break if i=="W": if countG2==0: Flag=False break #print(Flag,FlagW) if countG!=countR or not Flag or not FlagW: print("impossible") else: print("possible")