#include #define rep(i,N) for(ll (i)=0;(i)<(N);(i)++) #define chmax(x,y) x=max(x,y) #define chmin(x,y) x=min(x,y) using namespace std; typedef long long ll; typedef pair P; const int mod = 1000000007; const int INF = 1001001001; void solve() { string s; cin >> s; int n = s.length(); vector cnt(3); // reverse(s.begin(), s.end()); bool ok = true; rep(i, n) { if (s[i] == 'W') cnt[0]++; if (s[i] == 'G') { cnt[1]++; cnt[0]--; if (cnt[0] < 0) ok = false; } if (s[i] == 'R') { cnt[2]++; cnt[1]--; if (cnt[1] < 0) ok = false; } } if (cnt[1] != 0) ok = false; string ans = "possible"; if (!ok) ans = "impossible"; cout << ans << endl; } int main() { int test; cin >> test; rep(i, test) solve(); }