#include using namespace std; using ll = long long; using P = pair; using T = tuple; #define al(a) a.begin(), a.end() #define ral(a) a.rbegin(), a.rend() #define sz(a) (int)a.size() #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define db(a, b) cout << #a << ": " << a << " " << #b << ": " << b << endl; int main() { int t; cin >> t; rep(ti, t) { string s; cin >> s; int n = sz(s); bool ok = true; int g = 0, r = 0; drep(i, n) { if (s[i] == 'W' && (!g || !r)) { ok = false; } if (s[i] == 'G') { g++; if (g > r) ok = false; } if (s[i] == 'R') { r++; } } if (g != r) ok = false; if (ok) cout << "possible\n"; else cout << "impossible\n"; } return 0; }