#include using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define DEBUG void is_possible(string s){ stack bus; reverse(s.begin(), s.end()); string result = "possible"; // cout << s << endl; bool white_ok = false; rep(i, s.length()){ if (white_ok){ if (s[i] == 'R') bus.push(1); else if (s[i] == 'G') if (!bus.empty()) bus.pop(); else{ result = "impossible"; break; } } else{ if (s[i] == 'R'){ bus.push(1); } else if (s[i] == 'G') if (!bus.empty()){ bus.pop(); white_ok = true; } else{ result = "impossible"; break; } else if (s[i] == 'W'){ result = "impossible"; break; } } } if (!bus.empty()) result = "impossible"; cout << result << endl; return; } int main() { int n; string s; cin >> n; rep(i, n){ cin >> s; is_possible(s); } return 0; }