#!/usr/bin/env python #coding:utf8 def read(): return raw_input() def work(s): chList = "WGR" val = [0, 0, 0] for ch in s: val[chList.find(ch)] += 1 if not (val[0] >= val[1] >= val[2]): print "impossible" return if val[0] >= val[1] and val[1] == val[2] and val[2] > 0 and s[-1] == 'R': print "possible" else: print "impossible" if __name__ == "__main__": for i in range(input()): work(read())