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