#include #include #include #include #include #include #include using namespace std; int T; const int MAXN = 1010; char str[MAXN]; int nums[27]; long long C[MAXN][MAXN]; long long mod = 1e9 + 7; int main() { //freopen("in.txt","r",stdin); scanf("%d",&T); C[0][0] = 1; for (int i = 1;i <= 1000;i ++) { for (int j = 0;j <= 1000;j ++) { if(j == 0) C[i][j] = 1; else { C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod; } } } // cout << C[5][2] << " " << C[4][2] << endl; while(T --) { scanf("%s",str); int n = strlen(str); memset(nums,0,sizeof(nums)); for (int i = 0;i < n;i ++) { nums[str[i] - 'a'] ++; } int cnt = 0; for (int i = 0;i < 26;i ++) { if(nums[i] % 2 == 1) { cnt ++; } nums[i] /= 2; } if(cnt >= 2) { puts("0"); continue; } n /= 2; long long ans = 1; for (int i = 0;i < 26;i ++) { ans = ans * C[n][nums[i]] % mod; n -= nums[i]; } printf("%I64d\n",ans); } }