T = int(input()) for _ in range(T): S = input() W_cnt, G_cnt, R_cnt = 0, 0, 0 for S_i in S: if S_i == 'W': W_cnt += 1 if S_i == 'G': G_cnt += 1 if S_i == 'R': R_cnt += 1 if W_cnt < G_cnt or G_cnt < R_cnt: print('impossible') break else: if G_cnt == R_cnt: print('possible') else: print('impossible')