T = int(input()) for i in range(T): possible = True S = input()[::-1] course = [] for j in range(len(S)): if S[j] == 'R': course.append('R') if S[j] == 'G': if 'R' in course: course[course.index('R')] = 'G' else: possible = False if S[j] == 'W': if 'G' in course: course[course.index('G')] = 'W' elif not 'W' in course: possible = False if possible: print('possible') else: print('impossible')