#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const ll MOD = 998244353;
 
// Maximum total count among test cases is <= 5e5.
const int MAXN = 500000;
 
vector<ll> fact(MAXN+1), invfact(MAXN+1);
 
// Fast exponentiation modulo mod.
ll modexp(ll base, ll exp, ll mod=MOD) {
    ll res = 1;
    base %= mod;
    while(exp > 0) {
        if(exp & 1)
            res = (res * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return res;
}
 
// Precompute factorials and inverse factorials up to MAXN.
void precomputeFactorials() {
    fact[0] = 1;
    for (int i = 1; i <= MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }
    invfact[MAXN] = modexp(fact[MAXN], MOD - 2, MOD);
    for (int i = MAXN; i > 0; i--) {
        invfact[i-1] = (invfact[i] * i) % MOD;
    }
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    precomputeFactorials();
 
    int t; 
    cin >> t;
    while(t--){
        vector<int> c(26);
        ll total = 0;
        for (int i = 0; i < 26; i++){
            cin >> c[i];
            total += c[i];
        }
        // Total length of string must be positive.
        if(total == 0){
            cout << 0 << "\n";
            continue;
        }
 
        int oddCount = (total + 1) / 2; // positions: 1,3,5,...
        int evenCount = total / 2;      // positions: 2,4,6,...
 
        // DP for subset-sum: For each letter (with c[i]>0), decide if it goes to odd positions.
        // We need the sum of counts chosen to equal oddCount.
        vector<ll> dp(oddCount+1, 0);
        dp[0] = 1;
        for (int i = 0; i < 26; i++){
            if(c[i] <= 0) continue; // ignore letters that do not appear.
            int cnt = c[i];
            for (int j = oddCount; j >= cnt; j--){
                dp[j] = (dp[j] + dp[j - cnt]) % MOD;
            }
        }
 
        ll waysPartition = dp[oddCount] % MOD;
 
        // If no valid partition exists, answer is 0.
        if(waysPartition == 0){
            cout << 0 << "\n";
            continue;
        }
 
        // The arrangement factor is:
        // (fact[oddCount] * fact[evenCount]) / (∏_{i=0}^{25} c[i]!)
        ll arrangement = (fact[oddCount] * fact[evenCount]) % MOD;
        for (int i = 0; i < 26; i++){
            if(c[i] > 0){
                arrangement = (arrangement * invfact[c[i]]) % MOD;
            }
        }
 
        ll ans = (waysPartition * arrangement) % MOD;
        cout << ans % MOD << "\n";
    }
    return 0;
}
