#include "bits/stdc++.h" using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 1000000007; int main(){ int n; cin>>n; REP(i,n){ string s; cin>>s; int cnt=0; int w=0; int gr=0; bool flag=1; REP(j,GET_ARRAY_SIZE(s)){ if(s[j]=='G'){ cnt++; if(cnt==0)gr++; } else if(s[j]=='R'){ cnt--; if(cnt==0)gr++; } else if(s[j]=='W'){w++;} if(cnt<0)flag=0; } string ans=cnt==0&&flag&&gr<=w?"possible":"impossible"; print(ans); } }