# -*- coding: utf-8 -*- """ No.154 市バス https://yukicoder.me/problems/no/154 """ import sys from sys import stdin input = stdin.readline def solve(S): G_stack = [] W_stack = [] for s in S: if s == 'W': W_stack.append(1) elif s == 'G': if len(W_stack) == 0: return 'impossible' else: _ = W_stack.pop() G_stack.append(1) elif s == 'R': if len(G_stack) == 0: return 'impossible' else: _ = G_stack.pop() if len(G_stack) != 0: return 'impossible' return 'possible' def main(args): T = int(input()) for _ in range(T): S = input().strip() ans = solve(S) print(ans) if __name__ == '__main__': main(sys.argv[1:])