#include "bits/stdc++.h" using namespace std; #define rep(i, n) for(int i = 0; i < (n); i++) #define REP(i, s, n) for(int i = (s); i < (n); i++) #define all(co) begin(co), end(co) #define maxup(ans, x) (ans = (ans < x ? x : ans)) #define minup(ans, x) (ans = (ans > x ? x : ans)) using P = pair; signed main() { int x = 0; int n; cin >> n; rep(_, n) { string s; cin >> s; int w = 0, g = 0, r = 0; bool ok = true; bool wg = false; for (char c : s) { if (c == 'W') { w++; wg = true; } if (c == 'G') { g++; wg = false; } if (c == 'R') { r++; } if (g > w || r > g) { ok == false; break; } } cout << (wg && ok && g == r ? "possible" : "impossible") << endl; } //cin >> n; }