#include #include #include #include #define rep(n) for(int i = 0; i < n; ++i) using namespace std; int main(void) { int t, s; cin >> t; rep(s) { int c = 0; bool flag = true; string str; cin >> str; rep(str.size()) { if (str[i] == 'G') { ++c; } else if (str[i] == 'R') { --c; } if (c < 0) { flag = false; break; } } if (flag) { if (c == 0) { cout << "possible" << endl; } else { cout << "impossible" << endl; } } else { cout << "impossible" << endl; } } }