#include #include #include #include #include #include using namespace std; #define LL long long #define MOD 1000000007 char ch[1010]; int o[30]; LL fac[1005],inv[1005]; inline void Pre() { fac[0]=1; for (int i=1;i<=1000;i++) (fac[i]=fac[i-1]*i)%=MOD; inv[1]=1; for (int i=2;i<=1000;i++) (inv[i]=(MOD-MOD/i)*inv[MOD%i])%=MOD; inv[0]=1; for (int i=1;i<=1000;i++) (inv[i]*=inv[i-1])%=MOD; } int main(){ Pre(); int T; scanf("%d", &T); while(T --){ int n; scanf("%s", ch + 1); n = strlen(ch + 1); memset(o, 0, sizeof(o)); for(int i = 1; i <= n; i ++) o[ch[i] - 'a' + 1] ++; int tt = 0; for(int i = 1; i <= 26; i ++) if(o[i] % 2 == 1) tt ++; tt -= (n % 2); if(tt != 0){ puts("0"); continue; } LL ans = fac[n / 2]; for(int i = 1; i <= 26; i ++){ o[i] /= 2; ans *= inv[o[i]]; ans %= MOD; } printf("%I64d\n", ans); } return 0; }