#include #include using namespace std; int main(void) { int t; cin >> t; for(int i = 0; i < t; i++) { string str; int stack = 0; cin >> str; int size = str.size(); if(size < 3 || str[size - 1] == 'W') { cout << "impossible" << endl; continue; } for(int j = 0; j < size; j++) { if(str[j] == 'G') stack++; else if(str[j] == 'R') stack--; if(stack < 0) break; } if(stack == 0) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }