T = int(input()) for _ in range(T): S = input().strip() count_G = S.count('G') count_R = S.count('R') count_W = S.count('W') if count_G != count_R: print("impossible") continue if count_W < count_G: print("impossible") continue available_W = 0 available_G = 0 possible = True for c in S: if c == 'W': available_W += 1 elif c == 'G': if available_W < 1: possible = False break available_W -= 1 available_G += 1 elif c == 'R': if available_G < 1: possible = False break available_G -= 1 if possible and available_G == 0: print("possible") else: print("impossible")