for _ in range(int(input())): R,G = 0,0 for s in input(): if s == "R": R += 1 if s == "G": G += 1 if R > G: print("impossible") break else: if R == G: print("possible") else: print("impossible")