def check(S): W = 0 R = 0 hasW = False hasR = False hasG = False for c in S: if c == 'W': W += 1 elif c == 'G': W -= 1 if W < 0: return False for c in S[::-1]: if c == 'W': if not hasG: return False elif c == 'G': hasG = True R -= 1 else: R += 1 if R < 0: return False return R == 0 T = input() for i in xrange(T): S = raw_input() if check(S): print 'possible' else: print 'impossible'