def check(str): if str.count('R') != str.count('G'): return 'impossible' elif str.count('W') < str.count('R'): return 'impossible' lines = [0] * str.count('R') for s in str: if s == 'W': if 0 not in lines: return 'impossible' elif s == 'G': try: lines[lines.index(0)] = 1 except: return 'impossible' elif s == 'R': try: lines[lines.index(1)] = 2 except: return 'impossible' return 'possible' T = input() for t in range(T): print check(raw_input())