T = int(input()) for _ in range(T): S = list(input()) cntR = S.count("R") cntG = S.count("G") cntW = S.count("W") if cntR != cntG or cntR == 0 or cntW < cntG: print("impossible") continue flag = 1 nR, nW, nG = 0, 0, 0 for s in S: if s == "G": nG += 1 elif s == "R": nR += 1 else: nW += 1 if nW < nG or nG < nR or (cntG == nG and cntW != nW) or (cntR == nR and cntW != nW): print("impossible") flag = 0 break if flag == 0: continue print("possible")