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