#include #include #include #include #include #include #include #include #include #include #define REP(i, n) for(int i = 0;i < (n); i++) #define REP2(i, x, n) for(int i = (x); i < (n); i++) #define REPR(i, n) for(int i = (n); i >= 0; i--) #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c).end()) #define LL long long #define LD long double #define PI 3.14159265358979 using namespace std; //================================================ int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; vectorans(T); int wCount = 0; int gCount = 0; int rCount = 0; string S = ""; REP(i, T) { cin >> S; if (S.substr(S.size() - 1, 1) != "R") { ans[i] = "impossible"; continue; } REP(j, S.size()) { if (S[j] == 'W') wCount++; if (S[j] == 'G') gCount++; if (S[j] == 'R') rCount++; } if (gCount == rCount && gCount <= wCount) { ans[i] = "possible"; } else { ans[i] = "impossible"; } } REP(i, T) cout << ans[i] << "\n"; return 0; }