def judge(list): cnt_r = 0 cnt_g = 0 cnt_w = 0 pori = True for i in range(1,len(list)+1): if list[-i] == 'R': cnt_r += 1 elif list[-i] == 'G': cnt_g += 1 elif list[-i] == 'W': cnt_w += 1 if cnt_g > cnt_r: pori = False break elif cnt_g == 0 and cnt_w > 0: pori = False break elif cnt_r == 0 and cnt_w > 0: pori = False break if cnt_g != cnt_r: pori = False elif cnt_w < cnt_g or cnt_w < cnt_r: pori = False elif list[0] == 'G' or list[0] == 'R' or list[1] == 'R': pori = False if pori == True: print("possible") elif pori == False: print("impossible") T = int(input()) L = [] for i in range(T): S = input() L.append(list(S)) for i in range(T): judge(L[i])