#include #include #include #include #include #include #include #include #include #include #include #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) typedef long long ll; using namespace std; int inputValue(){ int a; cin >> a; return a; }; template void output(T a, int precision) { if(precision > 0){ cout << setprecision(precision) << a << "\n"; } else{ cout << a << "\n"; } } int main() { // source code int N = inputValue(); rep(i, N){ string s; cin >> s; int check = 0; rep(j, s.size()){ if (s[j] == 'G') { check++; } if (s[j] == 'R') { check--; } if (check < 0) { break; } } output((check == 0) ? "possible" : "impossible", 0); } return 0; }