#include using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; ++i) { string s; cin >> s; int a = 0; bool p = true; for (char c : s) { if (c == 'G') ++a; if (c == 'R') { --a; if (a < 0) p = false; } } if (a) p = false; cout << (p ? "possible" : "impossible") << endl; } }