for _ in[0]*input(): a=0 for c in raw_input(): if c=="G":a+=1 if c=="R"and a>0:a-=1 print["","im"][a>0]+"possible"