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" g_cnt = 0 r_cnt = 0 for c in t: if c == "G": g_cnt += 1 elif c == "R": r_cnt += 1 if g_cnt < r_cnt: return "impossible" return "possible" if __name__ == "__main__": que = No154() ans = que.solve() for s in ans: print(s)