#include typedef long long ll; using namespace std; int INF = 1e9; int MOD = 1e9+7; main(){ int N; cin >> N; for(int i = 0;i < N;i++){ string S; cin >> S; reverse(S.begin(),S.end()); int cnt = 0; for(char c:S){ if(cnt < 0)break; if(c == 'R')cnt++; if(c == 'G')cnt--; } if(cnt != 0)cout << "impossible" << endl; else cout << "possible" << endl; } }