for i in range(int(input())): cntw = cntg = cntr = 0 possible = True for s in input(): if s == 'W': cntw += 1 if s == 'G': cntg += 1 if s == 'R': cntr += 1 if cntw < cntg or cntg < cntr: possible = False if cntg != cntr or (cntw != 0 and cntg == 0): possible = False if possible: print('possible') else: print('impossible')