for _ in[0]*input(): s=raw_input() w=g=r=0 for c in s[::-1]: if c=="R": r+=1 elif c=="G": g+=1 if g>r: print"impossible" break elif c=="W": w+=1 if g>0 and r>0: g-=1 r-=1 w-=1 if g==0 and r==0: print"possible" else: print"impossible"