import re T = int(input()) for i in range(T): S = input() pre_S = '' while (S != pre_S): pre_S = S S = re.sub(r'W+GR', '', S) if S == '': print('possible') else: print('impossible')