for _ in range(int(input())): r, g = 0, 0 S = input() for c in S[::-1]: if c == 'R': r += 1 if c == 'G': if r > 0: g += 1 else: print('impossible') break if c == 'W': if g == 0: print('impossible') break else: if r == g and S[0] == 'W': print('possible') else: print('impossible')