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