t = int(input()) ans = [] for i in range(t): s = list(input()) flag_a = 0 flag_b = 1 count_w = 0 count_g = 0 count_r = 0 for x in s: if x == 'W': count_w += 1 flag_b = 1 elif x == 'G': count_g += 1 flag_b = 0 elif x == 'R': count_r += 1 if count_g < count_r or count_w < count_g: flag_a = 1 break if flag_a == flag_b == 0 and count_w >= count_g == count_r: ans.append('possible') else: ans.append('impossible') for j in ans: print(j)