T=int(raw_input()) for i in range(T): S=raw_input() Rcnt=0 Gcnt=0 ok=True oneBus =False for s in S[::-1]: if s=='R': Rcnt+=1 if s=='G': if Rcnt <= 0: ok=False break Rcnt-=1 Gcnt+=1 if s=='W': if Gcnt <= 0 and oneBus==False: ok=False break Gcnt=max(0,Gcnt-1) oneBus = True if ok and Rcnt==0 and Gcnt==0: print 'possible' else: print 'impossible'