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