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