def judge(list):
    cnt_r = 0
    cnt_g = 0
    cnt_w = 0
    pori = False
    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:
            break
        elif cnt_g == 0 and cnt_w > 0:
            break
        elif cnt_r == 0 and cnt_w > 0:
            break

        if i == len(list):
            pori = True

    if list[0] == 'G' or list[0] == 'R' or list[1] == 'R':
        pori = False        
    if cnt_g != cnt_r:
        pori = False
    if cnt_w < cnt_g or cnt_w < cnt_r:
        pori = False
            
    if pori == True:
        print("possible")
    if 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])