from collections import * from heapq import * import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def MF(): return map(float, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LF(): return list(map(float, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): t=II() for _ in range(t): s=input() cw=cg=cr=0 for c in s: if c=="W": cw+=1 if c=="G": cg+=1 if cg>cw: print("impossible") break if c=="R": cr+=1 if cr>cg or cr>cw: print("impossible") break else: if cr==cg: print("possible") else: print("impossible") main()