for _ in range(int(input())): C = input()[::-1] cr,cg,cw = C.count("R"),C.count("G"),C.count("W") if cr == cg and cw >= cr: Q = [0,0] while C: color = C[0] C = C[1:] if color == "R": Q[0] += 1 elif color == "G" and Q[0]>Q[1]: Q[1] += 1 elif color == "G": print("impossible") break elif Q[0]*Q[1]==0 and color == "W": break else: print("possible") else: print("impossible")