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