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