using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static int N = int.Parse(Console.ReadLine());
    static void Main()
    {
        for (int i = 0; i < N; i++)
        {
            string S = Console.ReadLine();
            Console.WriteLine(Hantei(S));
        }
    }
    static string Hantei(string s)
    {
        int rcnt = 0;
        int wcnt = 0;
        int gcnt = 0;
        char last = ' ';
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'W') wcnt++;
            if (s[i] == 'G') gcnt++;
            if (s[i] == 'R') rcnt++;
            else last = s[i];
            if (!(wcnt>=gcnt&&gcnt>=rcnt)) return "impossible";
        }
        if (gcnt == rcnt && last == 'G') return "possible";
        else return "impossible";
    }
}