N = int(input()) ans = ["impossible", "possible"] for _ in range(N): S = input() rcnt = 0 gcnt = 0 wcnt = 0 flg = True for s in S[::-1]: if s == "R": rcnt += 1 elif s == "G": if rcnt == 0: flg = False gcnt += 1 rcnt -= 1 elif s == "W": if gcnt: wcnt += 1 gcnt -= 1 elif wcnt == 0: flg = False if rcnt or gcnt: flg = False print(ans[flg])