#include char s[5000]; typedef long long ll; typedef long long num; const ll mod = 1000000007; ll p[5000]; num exgcd(num a,num b,num &A,num &B) { if(!b){ A = 1; B = 0; return a; } num r = exgcd(b,a%b,B,A); B = B - (a/b)*A; return r; } num inv_at_mod(num x,num m) { num i,t; if(1!=exgcd(x,m,i,t)) return 0; i = i % m; if( i < 0 ) i += m; return i; } int c[30]; int main() { p[0] = 1; for(int i=1; i<5000; ++i) p[i] = i * p[i-1] % mod; int T; scanf("%d", &T); while(T--) { scanf("%s", s); for(int i=0; i<30; ++i) { c[i] = 0; } int len = 0; for(int i=0; s[i]; ++i) { c[s[i]-'a'] ++; ++len; } int n_odd = 0; ll z = p[len/2]; for(int i=0; i<26; ++i) if( c[i] ) { if( c[i] % 2 == 1 ) { ++n_odd; if( c[i] > 2 ) { z = z * inv_at_mod(p[c[i]/2], mod) % mod; } continue; } z = z * inv_at_mod(p[c[i]/2], mod) % mod; } if( n_odd > 1 ) z = 0; printf("%I64d\n", z); } return 0; }