def judge(S): if not (S.count('G') == S.count('R')) or S.count('W') < S.count('G'): return False cnt = 0 wcnt = 0 for x in S: if x == 'G': cnt += 1 wcnt = 0 elif x == 'R': cnt -= 1 else: wcnt += 1 if cnt < 0: return False if wcnt > 0: return False return True N = int(input()) for i in range(N): S = input() if judge(S): print("possible") else: print("impossible")