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