for _ in xrange(input()): s = raw_input() w, g, r = s.count('W'), s.count('G'), s.count('R') if w == 0 or g == 0 or r == 0: print 'impossible' continue if w < r or w < g: print 'impossible' continue if s.rindex('W') > s.rindex('G') or s.rindex('W') > s.rindex('R'): print 'impossible' continue left = 0 for c in s: if c == 'G': left += 1 elif c == 'R': left -= 1 if left < 0: break if left != 0: print 'impossible' continue print 'possible'