for i in range(int(input())): s = input() w, g, r, l = 0, 0, 0, s.count("G") f = 1 if s[0] != "W" else 0 for j in s: 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 if f : break print("possible" if f == 0 and g == 0 else "impossible")