#include #include using namespace std; int main() { int T; cin>>T; while (T--) { string s; cin>>s; int cnt[128]={}; string res="possible"; for(auto& c: s) { ++cnt[c]; if (c=='R' and !(cnt['W']>=cnt['G'] and cnt['G']>=cnt['R'])) res="impossible"; if (c=='G' and !(cnt['W']>=cnt['G'])) res="impossible"; } if (cnt['G']!=cnt['R'] or cnt['G']==0) res="impossible"; cout<