#include using namespace std; int main(){ int t; cin >>t; while(t--){ string s; cin >> s; int w = 0,g = 0,count =0; bool f = true; for(int i =0;i < s.size();i++){ if(s[i] == 'W') w++; if(s[i] == 'G'){ count += --w; g++; if(count < 0){ cout << "impossible" << endl; f = false; break; } } if(s[i] == 'R' && --g < 0){ cout << "impossible" << endl; f = false; break; } } if(f) cout << (w == 0 && g == 0 ? "possible" : "impossible") << endl; } }