def solve(): S = input() flg = False cnt = 0 for s in S[::-1]: if s == "W": if not flg: print("impossible") return elif s == "R": cnt += 1 flg = True else: cnt -= 1 if cnt < 0: print("impossible") return if S[0] != "W": print("impossible") else: print("possible") for _ in range(int(input())): solve()