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