t = int(input()) for i in range(t): s = list(input()) count = 0 f = 0 while(len(s)): wgr = s.pop(0) if wgr == 'W': continue elif wgr == 'G': count += 1 elif wgr == 'R': count -= 1 if count < 0: f = 1 if f == 0 and count == 0: print('possible') else: print('impossible')