import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) def main(): S = input().rstrip() W = 0 G = 0 for s in S: if s == "W": W += 1 elif s == "G": if not W: return False W -= 1 G += 1 else: if not G: return False G -= 1 return G == 0 T = int(input()) for _ in range(T): if main(): print("possible") else: print("impossible")