T=int(input()) for i in range(T): w=g=r=0 t=True S=list(input()) for j in range(len(S)): if not w>=g>=r: print("impossible") t=False break if S[j]=="W": w+=1 la=j if S[j]=="G": g+=1 l=j if S[j]=="R": r+=1 if t: if g==r and g>0 and l>la: print("possible") else: print("impossible")