#include int main() { int t; std::cin >> t; while (t--) { std::string s; std::cin >> s; bool flg = true; int a = 0, w = 0; std::deque q; for (auto c : s) { switch (c) { case 'W': w++; break; case 'G': q.push_back(1); a = std::max(a, (int)q.size()); break; case 'R': if (q.size() == 0) { goto g; } else { q.pop_back(); } } } std::cout << (q.size() == 0 && w >= a ? "possible" : "impossible") << std::endl; continue; g: std::cout << "impossible" << std::endl; } return 0; }