#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(); 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 && str[size - 1] != 'W') cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }