def check(str): if str.count('R') != str.count('G'): return 'impossible' elif str.count('W') < str.count('R'): return 'impossible' elif str.count('W') * str.count('R') * str.count('G') == 0: return 'impossible' else: coming_green = False coming_red = 0 for s in str: if s == 'W': coming_green = True elif s == 'G': if coming_green == False: return 'impossible' else: coming_green = False coming_red += 1 elif s == 'R': if coming_red < 1: return 'impossible' else: coming_red -= -1 if coming_green * coming_red != 0: return 'impossible' else: return 'possible' T = input() for t in range(T): print check(raw_input())