def solver(): S = input() G = 0 _g = S.count("G") _r = S.count("R") _w = S.count("W") if _g != _r: return "impossible" if _r > _w: return "impossible" line = _r for i in S: if i == "G": G += 1 line -= 1 if i == "R": if G == 0: return "impossible" G -= 1 if i == "W" and line <= 0: return "impossible" if G > 0: return "impossible" return "possible" T = int(input()) ans = [solver() for i in range(T)] for i in ans: print(i)