# -*- coding: utf-8 -*- T = int(input()) for i in range(T): S = input() cnt = 0 for x in S: if x == 'G': cnt += 1 elif x == 'R': cnt -= 1 if cnt < 0: print('impossible') break else: if cnt > 0: print('impossible') else: print('possible')