#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import collections

W = "W"
G = "G"
R = "R"


def solve(memo):
    counter = collections.Counter()
    for light in memo[::-1]:
        if light == R:
            counter[R] += 1
        elif light == G:
            counter[R] -= 1
            counter[G] += 1
            if counter[R] < 0:
                return False
        elif light == W:
            if counter[G] > 0:
                counter[G] -= 1
                counter[W] += 1
            elif counter[W] == 0:
                return False
    return counter[R] == counter[G] == 0


if __name__ == "__main__":
    t = int(input())
    for i in range(t):
        if solve(input()):
            print("possible")
        else:
            print("impossible")