for _ in range(int(input())): S = input() r, g, w = 0, 0, 0 ls = "" f = True for s in S: if s == "R": r += 1 else: ls = s if s == "G": g += 1 else: w += 1 if w < g or g < r: f = False if not f or r != g or ls != "G": print("impossible") else: print("possible")