#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ string s; cin >> s; bool ok = true; int Ws = 0,Gs = 0,Rs = 0; for(auto c : s){ if(c == 'W') Ws++; else if(c == 'G') Gs++; else Rs++; if(Ws < Gs || Gs < Rs) ok = false; } if(Gs != Rs || Rs == 0) ok = false; if(s.back() != 'R') ok = false; for(int i=s.size(); i--;){ if(s.at(i) == 'G') break; else if(s.at(i) == 'W'){ok = false; break;} } cout << (ok?"possible":"impossible") << "\n"; } }