#include #define WHITE 0 #define GREEN 1 #define RED 2 using namespace std; int T; string S; bool pos(){ int color[3] = {0}; int i; for(i = S.size() - 1; i >= 0; --i){ if(S[i] == 'G') ++color[GREEN]; if(S[i] == 'R') ++color[RED]; if(S[i] == 'W') ++color[WHITE]; if((color[WHITE] != 0 && color[GREEN] == 0) || (color[WHITE] != 0 && color[RED] == 0)) return false; if(color[GREEN] > color[RED]) return false; } if(color[GREEN] != color[RED]) return false; if(color[WHITE] < color[RED]) return false; return true; } int main(void){ cin >> T; int i; for(i = 0; i < T; ++i){ cin >> S; if(pos()) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }