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 countG2=0 countW2=0 countR2=0 if not t[:-2]=="G" and t[:-1]=="R": Flag=False if countG!=countR or not Flag or not FlagW: print("impossible") else: print("possible")