#pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #include using namespace std; #define N 1005 #define LL long long const int mod = 1000000007; char ss[N]; int cnt[26]; int fac[N]; int fpow(int a, int p) { int res = 1; while (p) { if (p & 1) res = (LL)res * a % mod; p >>= 1; a = (LL)a * a % mod; } return res; } int main() { int test; fac[0] = 1; for (int i = 1; i < N; i++) fac[i] = (LL)fac[i - 1] * i % mod; scanf("%d", &test); for (int cas = 1; cas <= test; cas++) { scanf("%s", ss); int n = strlen(ss); memset(cnt, 0, sizeof(cnt)); for (int i = 0; i < n; i++) { cnt[ss[i] - 'a']++; } int odd = 0; for (int i = 0; i < 26; i++) { if (cnt[i] & 1) odd++; } if (odd <= 1) { int res = fac[n >> 1]; for (int i = 0; i < 26; i++) { res = (LL)res * fpow(fac[cnt[i] >> 1], mod - 2) % mod; } printf("%d\n", res); } else { puts("0"); } } return 0; }