import sys, math sys.setrecursionlimit(10**8) sys.set_int_max_str_digits(0) INF = 1e18 MOD = 998244353 from bisect import bisect_left, bisect_right from collections import deque, defaultdict, Counter from itertools import product, combinations, permutations, groupby, accumulate from heapq import heapify, heappop, heappush input = sys.stdin.readline def I(): return input().rstrip() def II(): return int(input().rstrip()) def IS(): return input().rstrip().split() def MII(): return map(int, input().rstrip().split()) def LI(): return list(input().rstrip()) def TII(): return tuple(map(int, input().rstrip().split())) def LII(): return list(map(int, input().rstrip().split())) def LSI(): return list(map(str, input().rstrip().split())) def GMI(): return list(map(lambda x: int(x) - 1, input().rstrip().split())) def kiriage(a, b): return (a+b-1)//b T = II() d = {} d['W'] = 0 d['G'] = 1 d['R'] = 2 for i in range(T): S = I() data = [list() for _ in range(3)] for i, s in enumerate(S): data[d[s]].append(i) # 一個はあるはず # G, R は同じ個数のはず # W のカウントは G より多いはず if len(data[0]) == 0 or len(data[1]) == 0 or len(data[2]) == 0 or len(data[1]) != len(data[2]) or len(data[0]) < len(data[1]): print('impossible') continue # 一番右にある G をメモ rightest_G = data[1][-1] flag = True while data[2]: # R pos2 = data[2].pop() # G: 貪欲に一番後ろを取る pos1 = data[1].pop() # W: 貪欲に一番後ろを取る pos0 = data[0].pop() # 順番の判定 if not (pos0 < pos1 < pos2): flag = False break # break しなかったら次のペアへ # W が残っている場合、最右のG より 全部左側にあるべき if len(data[0]) > 0: if data[0][-1] > rightest_G: flag = False if flag: print('possible') else: print('impossible')