#include #include #include #include #include #include #include using namespace std; const int Maxn=1005,P=1e9+7; int T,n; char s[Maxn]; int tong[35]; long long ans; int C[Maxn][Maxn]; int main() { //freopen("B.in","r",stdin); //freopen("B.out","w",stdout); int i,j,x; C[0][0]=C[1][0]=C[1][1]=1; for (i=2;i<=1000;i++) { C[i][0]=1; for (j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%P; } scanf ("%d",&T); while(T--) { scanf ("%s",s+1); n=strlen(s+1); memset(tong,0,sizeof(tong)); for (i=1;i<=n;i++) tong[s[i]-96]++; x=0;for (i=1;i<=26;i++) if (tong[i]&1) x++; if (x!=n%2) printf ("0\n"); else { if (n%2) { for (i=1;i<=26;i++) if (tong[i]&1) tong[i]--; n--; } for (i=1;i<=26;i++) tong[i]/=2;n/=2; ans=1; for (i=1;i<=26;i++) ans=ans*C[n][tong[i]]%P,n-=tong[i]; cout<