n=int(input()) a="impossible" for i in range(n): s=input().replace('W','') c=0 for x in s: if x=='G':c+=1 else:c-=1 if c<0: break print(a[(c==0)*2:])