#include #include using namespace std; int main() { int T; cin>>T; while (T--) { string s; cin>>s; int n=s.size(); int c[128]={}; int& r=c['R'], &g=c['G'], &w=c['W']; bool possible=true; for(int i=0;i=0&&s[i]!='R'&&possible;--i) if (s[i]=='W' or s[i]=='G') possible=false; if (r!=g or r>w) possible=false; cout<<(possible?"possible":"impossible")<