t=int(input()) sary=[list(input()) for _ in range(t)] from collections import Counter for s in sary: cs=dict(Counter(s)) if "W" not in cs or "G" not in cs or "R" not in cs: print("impossible") continue if cs["R"]!=cs["G"] or cs["R"]>cs["W"]: print("impossible") continue flg=True counter={"W":0,"G":0,"R":0} for x in s: counter[x]+=1 if counter["W"]>=counter["G"]>=counter["R"]: pass else: flg=False break if counter["G"]==cs["G"] and x=="W": flg=False break if flg: print("possible") else: print("impossible")