def solve(): S = input() t = 0 cnt = 0 for s in S[::-1]: if s == "W": if t != 2: print("impossible") return elif s == "R": cnt += 1 t = max(t, 1) else: cnt -= 1 if cnt < 0: print("impossible") return t = 2 if S[0] != "W" or cnt != 0: print("impossible") else: print("possible") for _ in range(int(input())): solve()