#include #include #include #include #include #include #include #include #include #include using namespace std; void solve(){ char c[2000]; scanf("%s", c); string s = c; deque w; deque g; deque r; int n = s.size(); for(int i=0; i 0){ w.pop_front(); g.push_back(i); }else{ cout << "impossible" << endl; return; } }else if(s[i] == 'R'){ if(g.size() > 0){ g.pop_front(); r.push_back(i); }else{ cout << "impossible" << endl; return; } } } if(g.size()>0){ cout << "impossible" << endl; }else if(w.size()>0 && r.size()>0 && w.back() > r.back()){ cout << "impossible" << endl; }else{ cout << "possible" << endl; } } int main(){ int T; cin >> T; while(T--){ solve(); } }