def solve(S): d = {'W': 0, 'G': 0, 'R': 0} for s in reversed(S): if s == 'G' and d['R'] == 0: return False elif s == 'W' and d['G'] == 0: return False d[s] += 1 if d['G'] > d['R']: return False return True if d['W'] >= d['G'] == d['R'] and 0 not in d.values() else False N = int(input()) for _ in range(N): print('possible' if solve(input()) else 'impossible')