def answer(): S = list(input()) W = [int(i == 'W') for i in S] G = [int(i == 'G') for i in S] R = [int(i == 'R') for i in S] N = len(S) from itertools import accumulate SW = list(accumulate(W)) SG = list(accumulate(G)) SR = list(accumulate(R)) for i in range(N): if SW[i]>=SG[i]>=SR[i]: continue else: print('impossible') return if SG[-1] != SR[-1]: print('impossible') return print('possible') return for _ in range(int(input())): answer()