#include #include #include using std::cin; using std::cout; using std::endl; char s[1009]; int arr[33]; typedef long long ll; const ll di=1000000007; ll res[1009]; ll gcd(ll a,ll b){ ll c=1; while(b){ c=a%b; a=b; b=c; } return a; } ll tmp[1009]; int main(){ ll a,b,c,d,e,f,g,h; cin>>b; while(b--){ scanf("%s",s); memset(arr,0,sizeof(arr)); for(d=0;s[d];d++){ arr[s[d]-'a']++; } for(d=0,g=0;d<26;d++){ if(arr[d]%2)g++; } if(g>1){ printf("0\n"); } else{ for(d=0,g=0;d<26;d++){ arr[d]/=2; g+=arr[d]; //printf("%d %d\n",d,arr[d]); } for(d=1;d<=g;d++){ res[d]=d; } for(d=0;d<26;d++){ if(arr[d]){ for(e=2;e<=arr[d];e++){ c=e; for(f=2;f<=g&&c>1;f++){ h=gcd(res[f],c); c/=h; res[f]/=h; } } } } for(e=1,d=2;d<=g;d++){ e*=res[d]; e%=di; } cout<