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