T = int(input()) for i in range(T): possible = True S = input() cnt = {'W': 0, 'G': 0, 'R': 0} for j in range(len(S)): cnt[S[j]] += 1 if S[j] == 'G' and cnt['G']>cnt['W']: possible = False if S[j] == 'R' and not cnt['R']<=cnt['G']<=cnt['W']: possible = False if cnt['G'] != cnt['R']: possible = False if possible: print('possible') else: print('impossible')