#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

bool check(const string &s) {
  int g = count(s.begin(), s.end(), 'G');
  int r = count(s.begin(), s.end(), 'R');
  int w = count(s.begin(), s.end(), 'W');

  if (!g || !r || !w) return false;
  if (s.find_last_of("W") > s.find_last_of("G")) return false;

  int p = 0, q = 0;
  for (char c: s) {
    if (c == 'W') ++p;
    else if (c == 'G') {
      if (--p < 0) return false;
      ++q;
    }
    else {
      if (--q < 0)
        return false;
    }
  }
  return !q;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int T;
  cin >> T;
  while (T--) {
    string s;
    cin >> s;
    if (check(s))
      cout << "possible" << endl;
    else
      cout << "impossible" << endl;
  }
  
  return 0;
}