import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): S = input().rstrip() G = 0 for s in S: if s == "G": G += 1 elif s == "R": if not G: print("impossible") return G -= 1 if G: print("impossible") else: print("possible") return T = int(input()) for _ in range(T): main()