for j in range(int(input())): #print(j) W,R,G = 0,0,0 lastw = 0 lastg = 0 S = input() for i,s in enumerate(S): if s == "W": W += 1 lastw = i if s == "R": R += 1 if s == "G": G += 1 lastg = i if W < G or G < R: print("impossible") break else: if lastw > lastg: print("impossible") continue if R == G and R > 0: print("possible") else: print("impossible")