#include #include #include #include #include #include #include #include #include #include #define mod 1000000007 #define ll long long using namespace std; ll extend_gcd(ll a,ll b,ll &x,ll &y) { if(a==0&&b==0) return -1;//无最大公约数 if(b==0){x=1;y=0;return a;} ll d=extend_gcd(b,a%b,y,x); y-=a/b*x; return d; } ll mod_reverse(ll a,ll n) { ll x,y; ll d=extend_gcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1; } ll c(ll m,ll n) { ll i,j,t1,t2,ans; t1=t2=1; for(i=n;i>=n-m+1;i--) t1=t1*i%mod; for(i=1;i<=m;i++) t2=t2*i%mod; return t1*mod_reverse(t2,mod)%mod; } int main() { int T,i,j,n,m,k; char s[1005]; int a[35]; scanf("%d",&T); while(T--) { k=0; scanf("%s",s); n=strlen(s); memset(a,0,sizeof(a)); for(i=0; s[i]!='\0'; i++) a[s[i]-'a']++; for(i=0; i<26; i++) { if(a[i]%2!=0) k++; if(k>1) break; } if(i!=26) { printf("0\n"); continue; } int sum=n/2; ll ans=1; for(i=0; i<26; i++) { if(a[i]&1) a[i]--; ans=(ans*c(a[i]/2,sum))%mod; sum-=a[i]/2; } printf("%lld\n",ans); } return 0; }