#include using namespace std; typedef long long ll; int main() { int t; cin>>t; while (t--) { string s; cin>>s; int w=0,g=0,r=0; bool f=true; char l; for (char c:s) { if (c=='W') w++,l=c; else if (c=='G') g++,l=c; else r++; if (w