class No154: n = 0 que_list = [] def __init__(self): self.n = int(input()) for i in range(self.n): self.que_list.append(input()) def solve(self): ans_list = [] for t in self.que_list: # type: str ans_list.append(self.check_str(t)) return ans_list @staticmethod def check_str(t): if not t.count("G") == t.count("R"): return "impossible" if t.count("G") == 0: return "impossible" if t.count("W") < t.count("G"): return "impossible" g_cnt = 0 r_cnt = 0 w_cnt = 0 is_req_green = False is_req_red = False for c in t: if c == "G": g_cnt += 1 is_req_green = False elif c == "R": r_cnt += 1 is_req_red = False elif c == "W": w_cnt += 1 is_req_green = True is_req_red = True if g_cnt < r_cnt: return "impossible" if w_cnt < r_cnt: return "impossible" if w_cnt < g_cnt: return "impossible" if is_req_red or is_req_green: return "impossible" return "possible" if __name__ == "__main__": que = No154() ans = que.solve() for s in ans: print(s)