def solver(): S = input() S.replace("W","") G = 0 for i in S: if i == "G": G += 1 if i == "R": if G == 0: return "impossible" G -= 1 if G > 0: return "impossible" return "possible" T = int(input()) ans = [solver() for i in range(T)] for i in ans: print(i)