#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define xx first #define yy second #define pb push_back #define mp make_pair #define LL long long #define inf INT_MAX/3 #define mod 1000000007ll #define PI acos(-1.0) #define linf (1ll<<60)-1 #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define REP(I,N) FOR(I,0,N) #define ALL(A) ((A).begin(), (A).end()) #define set0(ar) memset(ar,0,sizeof ar) #define vsort(v) sort(v.begin(),v.end()) #define setinf(ar) memset(ar,126,sizeof ar) //cout << fixed << setprecision(20) << p << endl; template inline T bigmod(T p,T e,T M){ LL ret = 1; for(; e > 0; e >>= 1){ if(e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);} template inline T modinverse(T a,T M){return bigmod(a,M-2,M);} LL ncr[1001][1001]; int ar[30]; int main() { // ios_base::sync_with_stdio(0); cin.tie(0); REP(i, 1001){ ncr[i][0] = 1; FOR(j, 1, i+1) ncr[i][j] = (ncr[i-1][j] + ncr[i-1][j-1]) % mod; } int T; cin >> T; while(T--){ string S; cin >> S; set0(ar); REP(i, S.size()) ar[S[i]-'a']++; int odd = 0; int sum = 0; REP(i, 30){ odd += ar[i]%2; ar[i] /= 2; sum += ar[i]; } if(odd > 1) { cout << 0 << endl; continue; } LL res = 1; REP(i, 30){ res = (res * ncr[sum][ar[i]]) % mod; sum -= ar[i]; } cout << res << endl; } }