def main(): n = int(input()) for _ in range(n): memo = input().strip()[::-1] W, G, R, pair_GR = 0, 0, 0, 0 b = True for s in memo: if s == 'R': R += 1 elif s == 'G' and G < R: G += 1 pair_GR += 1 elif s == 'W' and pair_GR > 0 and pair_GR > W: W += 1 elif s == 'W' and pair_GR <= W and not pair_GR == 0: continue else: b = False break if b and pair_GR == W and R == G: print('possible') else: print('impossible') main()