def delete_before(s, c, n): for i in range(n - 1, -1, -1): if s[i] == c: s[i] = '#' return True return False T = int(input()) for t in range(T): S = list(input()) if S[-1] != 'R': print('impossible') continue for i, c in enumerate(S): if c == 'G': if not delete_before(S, 'W', i): print('impossible') break if c == 'R': if not delete_before(S, 'G', i): print('impossible') break else: print('possible')