#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int v, w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int INF = INT_MAX / 4; int main() { int T; cin >> T; while (T--) { string S; cin >> S; int w = 0, g = 0, r = 0; bool ok = true; for (int i = 0; i < S.length(); i++) { if (S[i] == 'W') w++; if (S[i] == 'G') g++; if (S[i] == 'R') r++; if (w < g) ok = false; if (g < r) ok = false; } if (g != r) ok = false; cout << (ok ? "possible" : "impossible") << endl; } }