T = int(raw_input()) for loop in xrange(T): S = raw_input() w = last = 0 for s in S: if s == "G": last += 1 w = 0 elif s == "R": last -= 1 else: w += 1 if last < 0: print "impossible" break else: print "possible" if last == w == 0 else "impossible"