// ナニソレイミワカンナイ #include #include std::string S; int L; int count(char c){ int res = 0; for(int i=0;i=0;i--){ if(S[i] == c){return i;} } return -1; } int main(){ int T; std::cin >> T; while(T--){ std::cin >> S; L = S.size(); bool can = true; if(count('R') != count('G') || L < count('R') * 3){ can = false; }else{ int w = 0, g = 0, r = 0; while(r < L && S[r] != 'R'){r++;} for(;r g || g > r){can = false; break;} r++; while(r < L && S[r] != 'R'){r++;} w++; g++; } int g_mx = max('G'); for(int i=g_mx+1;i