#include #include #include #include #include #include #define ll long long using namespace std; char s[100010]; int main() { int t; cin>>t; while(t--){ ll ans=0; scanf("%s",s); int x=0; for(int i=0,j;s[i];i=j){ j=i; if(s[j]!='q') {j++;x=0;continue;} while(s[j]=='q') j++,x++; //cout<