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": gcnt += 1 if gcnt > rcnt: flg = False elif s == "W": wcnt += 1 if wcnt > gcnt: flg = False if gcnt > wcnt: flg = False print(ans[flg])