#include<bits/stdc++.h> #define ALL(v) std::begin(v),std::end(v) using lint=long long; using lubl=long double; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint q;std::cin>>q; while(q--){ std::string s;std::cin>>s; lint r=0,g=0,w=0; bool ng=false; for(char c:std::string(s.rbegin(),s.rend())){ (c=='R'?r:c=='G'?g:w)++; ng|=r<g||!g&&w; if(g<w)w=g; } ng|=r!=g||w!=g; std::cout<<(ng?"impossible":"possible")<<'\n'; } }