#!/usr/bin/env python3 def is_possible(s): w0 = 0 w1 = False g = 0 r = 0 for c in s: if c == 'W': w0 += 1 w1 = True elif c == 'G': if not w0: return False w1 = False w0 -= 1 g += 1 elif c == 'R': if not g: return False g -= 1 r += 1 if w1 or g: return False return True t = int(input()) for _ in range(t): s = input() print('possible' if is_possible(s) else 'impossible')