n = int(input()) for i in range(n): syscnt = 0 stk = [] s = raw_input() possible = True chkind = 0 wcount = 0 for j in range(len(s)): if s[j] == 'W': wcount += 1 if s[j] == 'G': stk.append('g') syscnt += 1 if wcount < syscnt: possible = False chkind = j elif s[j] == 'R': if not stk : possible = False else : stk.pop() if stk : possible = False for i in range(chkind,len(s)): if s[i] == 'W': possible = False print 'possible' if possible else 'impossible'