#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const string Y = "possible", N = "impossible"; string S; string solve() { int w = 0, ww = 0, g = 0; each(c, S) { if (c == 'W')w++, ww++; if (c == 'G') { g++; ww = 0; if (!w--)return N; } if (c == 'R') { if (!g--)return N; } } if (g > 0 || ww > 0)return N; return Y; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { cin >> S; cout << solve() << endl; } }