#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000007 int main(){ int n; cin>>n; rep(i,0,n){ string s; cin>>s; int c = 0; int flag = 1; int index1 = 0; int index2 = 0; int index3 = 0; for(;;){ if(index3==s.sz){ flag = 0; break; } if(index1>index2||index2>index3){ flag = 0; break; } if(s[index1]=='W'&&s[index2]=='G'&&s[index3]=='R'){ c++; if(c==count(all(s),'G')&&c==count(all(s),'R')){ break; } index1++; index2++; index3++; } else if(s[index3]!='R'){ index3++; } else if(s[index2]!='G'){ index2++; } else{ index1++; } } if(flag == 0){ cout << "impossible" << endl; } else{ cout << "possible" << endl; } } return 0; }