for _ in range(int(input())): S = input() a, b = 0, 0 f = True for s in S[::-1]: if s == "G": a += 1 if not a <= b: f = False if s == "R": b += 1 if not a < b: f = False if s == "W": if not a > 0: f = False if not f or a != b: print("impossible") else: print("possible")