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