# coding: utf-8 #yuki_154 t=int(raw_input()) for i in xrange(t): s=raw_input() rgcount=0 rflag=False gflag=False for j in xrange(len(s)): st=s[-1] if st=='R': rgcount+=1 rflag=True elif st=='G': rgcount-=1 gflag=True elif st=='W': if rflag==False or gflag==False: print "impossible" break if rgcount<0: print "impossible" break s=s[:-1] if len(s)==0: print "possible"