#include #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int T; cin >> T; while (T--) { string s; cin >> s; int n = s.size(); int g = 0, w = 0; int cnt = 0; bool ng = false; for (int i = 0; i < n; i++) { switch (s[i]) { case 'W': w++; break; case 'G': w--; if (w < 0) { ng = true; } g++; break; case 'R': g--; if (g < 0) { ng = true; } cnt++; break; } if (ng) break; } if (g > 0 || cnt == 0) ng = true; if (ng) cout << "impossible" << endl; else cout << "possible" << endl; } return 0; }