t = int(input()) ans = [] for i in range(t): s = list(input()) f = 0 flag = 1 count = 0 count_w = 0 count_g = 0 count_r = 0 while(s): wgr = s.pop(0) if wgr == 'W': flag = 1 count_w += 1 continue elif wgr == 'G': count += 1 count_g += 1 flag = 0 elif wgr == 'R': count -= 1 count_r += 1 if count < 0: f = 1 if f == 0 and count == 0 and count_w <= count_g and flag == 0: ans.append('possible') else: ans.append('impossible') for j in ans: print(j)