for i in range(int(input())): s = input() w, g, r, l = 0, 0, 0, s.count("G") f = 1 if s.count("G") != s.count("R") or s[0] != "W" else 0 for j in s: if f > 0 : break if j == "W": w += 1 if l == 0: f = 1 if j == "G": if l > 0 and w > 0: w -= 1; l -= 1; g += 1 else: f = 1 if j == "R": if g > 0: g -= 1; r += 1 else: f = 1 print("possible" if f == 0 and r == s.count("G") else "impossible")