#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; #define MOD 1000000007 // 10^9 + 7 #define INF 1000000000 // 10^9 #define LLINF 1LL<<60 string S[1000]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; for (int i = 0; i < N; i++) cin >> S[i]; for (int i = 0; i < N; i++) { int cntW, cntG, cntR; cntW = cntG = cntR = 0; bool flag = true; for (int j = S[i].size(); j >=0 && flag; j--) { if (S[i][j] == 'W') { cntG--; } if (S[i][j] == 'G') { cntR--; cntG++; } if (S[i][j] == 'R') cntR++; if (cntR < 0 || cntG < 0) flag = false; } if (cntR > 0 && cntG > 0) flag = false; if (flag) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }