#include #include using namespace std; int main() { ios::sync_with_stdio(false); int T; string S; cin >> T; for( int i=0; i> S; int d[3] = {0,0,0}; bool f = true; for( int i=S.size()-1; i>=0; i-- ){ switch( S[i] ){ case 'R': d[0]++; break; case 'G': if( d[0] == 0 ){ f = false; } else { d[0]--; d[1]++; } break; case 'W': if( d[1] > 0 ){ d[1]--; d[2]++; } else if( d[2] == 0 ) { f = false; } break; } if( !f ) break; } if( d[0] > 0 || d[1] > 0 ) f = false; if( f ) cout << "possible" << endl; else cout << "impossible" << endl; } }