#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int MOD = 998244353;
 
// Fast modular exponentiation.
ll modexp(ll base, ll exp, ll mod) {
    ll result = 1;
    base %= mod;
    while(exp > 0){
        if(exp & 1)
            result = (result * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return result;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    
    // Precompute factorials and inverse factorials up to the maximum sum possible.
    // The maximum total sum over any test case is at most 5e5.
    int maxN = 500000;
    vector<ll> fact(maxN+1), invfact(maxN+1);
    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 >= 1; i--){
        invfact[i-1] = invfact[i] * i % MOD;
    }
    
    while(t--){
        vector<int> c(26);
        int total = 0;
        for (int i = 0; i < 26; i++){
            cin >> c[i];
            total += c[i];
        }
        int oddCount = (total + 1) / 2; // number of odd positions (1-indexed)
        int evenCount = total / 2;      // number of even positions
        
        // DP to count valid partitions: dp[j] = number of ways to choose a subset (from letters with c > 0)
        // such that the sum of chosen counts equals j.
        vector<ll> dp(total+1, 0), newdp(total+1, 0);
        dp[0] = 1;
        for (int i = 0; i < 26; i++){
            if(c[i] == 0) continue; // skip letters with zero occurrences
            int x = c[i];
            fill(newdp.begin(), newdp.end(), 0);
            for (int j = 0; j <= total; j++){
                if(dp[j] != 0){
                    // Option 1: assign letter i to even positions (sum remains j)
                    newdp[j] = (newdp[j] + dp[j]) % MOD;
                    // Option 2: assign letter i to odd positions (sum increases by x)
                    if(j + x <= total)
                        newdp[j + x] = (newdp[j + x] + dp[j]) % MOD;
                }
            }
            dp.swap(newdp);
        }
        
        ll waysToAssign = dp[oddCount] % MOD;
 
        // The number of arrangements once the assignment is fixed is:
        // (oddCount)! * (evenCount)! divided by the product of factorials of counts of each letter.
        ll arrangement = (fact[oddCount] * fact[evenCount]) % MOD;
        for (int i = 0; i < 26; i++){
            arrangement = (arrangement * invfact[c[i]]) % MOD;
        }
 
        ll ans = (waysToAssign * arrangement) % MOD;
        cout << ans % MOD << "\n";
    }
    return 0;
}
