# coding: utf-8 import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def solve(N, l_memo): ans_list = [] for memo in l_memo: l_bus = list(memo) w_count = 0 g_count = 0 r_count = 0 all_flag = 0 w_flag = 1 for bus in l_bus: if bus == "W": w_count += 1 w_flag = 1 elif bus == "G": g_count += 1 w_flag = 0 elif bus == "R": r_count += 1 if w_count < g_count or g_count < r_count: all_flag = 1 break if all_flag == 0 and w_flag == 0 and w_count >= g_count == r_count: ans_list.append("possible") else: ans_list.append("impossible") return ans_list def main(): N = II() l_memo = [""] * N for i in range(N): l_memo[i] = str(input()) for ans in solve(N, l_memo): print(ans) if __name__ == "__main__": main()