#include #include void solve() { std::string s; std::cin >> s; int green; for (int i = 0; i < s.length(); i++) { if (s[i] == 'G') green++; if (s[i] == 'R') { if (green == 0) { std::cout << "impossible" << std::endl; return ; } green--; } } if (green == 0) { std::cout << "possible" << std::endl; } else { std::cout << "impossible" << std::endl; } } int main() { int n; std::cin >> n; for (int i = 0; i < n; i++) { solve(); } return 0; }