def main(): n = int(input()) for _ in range(n): memo = input()[::-1] W, G, R, pair_GR = 0, 0, 0, 0 last_R, last_G, b = False, False, True for s in memo: if s == 'R': R += 1 last_R = True elif s == 'G' and last_R: last_G = True if R > 0: R -= 1 pair_GR += 1 else: print('impossible') b = False break elif s == 'W' and last_R and last_G: if pair_GR == 0: print('impossible') b = False break elif pair_GR > 0: W += 1 else: print('impossible') b = False break if R == 0 and b: print('possible') main()