#include <bits/stdc++.h>
using namespace std;

template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int n;cin>>n;
  while(n--){
    bool out=false;
    string s;cin>>s;
    reverse(s.begin(),s.end());
    int r=0,b=0;bool B=0;
    for(auto p:s){
      if(p=='R')r++;
      if(p=='G'){
        r--;
        chmax(b,0);b++;
        if(r<0)out=1;
        B=1;
      }
      if(p=='W'){if(!B)out=1;b--;}
    }
    if(r||(b>0))out=1;
    cout<<(out?"impossible":"possible")<<endl;
  }
}