#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int T; cin >> T; rep(_,T) { string S; cin >> S; int W = 0, G = 0, R = 0; int N = S.size(); int ans = 1; rep(i,N) { if(S[i] == 'W') W++; if(S[i] == 'G') { G++, W--; if(W < 0){ ans = 0; break; } } if(S[i] == 'R') { R++, G--; if(G < 0){ ans = 0; break; } } } if(G > 0) ans = 0; cout << string(ans ? "" : "im") + "possible" << endl; } }