#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
//#define MOD 1000000007
#define FOR(i,a,b) for (int i = (a);i <= (b);i++)
#define FOD(i,a,b) for (int i = (b);i >= (a);i--)
#define ALL(x) (x).begin(),(x).end()
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
const int MOD = 998244353;
const int MAXN = 5e5 + 7;
int fact[MAXN],inv[MAXN],a[MAXN];
int P(ll a,ll b){
if (b==1)return a;
ll res = P(a,b/2)%MOD;res = res*res%MOD;
if (b&1)return res*a%MOD;
return res;
}
ll C(int k,int n){
return fact[n]*inv[n-k]%MOD*inv[k]%MOD;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
//freopen("cardscore.inp","r",stdin);
//freopen("cardscore.out","w",stdout);
fact[0] = 1;
FOR(i,1,MAXN - 1)fact[i] = fact[i-1]*i%MOD;
inv[MAXN - 1] = P(fact[MAXN - 1],MOD-2);
FOD(i,0,MAXN - 2)
inv[i] = inv[i+1]*(i+1)%MOD;
int tt;cin >> tt;
while(tt--){
int n = 26;
FOR(i,1,n)cin >> a[i];
ll s = 0;
FOR(i,1,n)s = s + a[i];
ll x = s / 2,y = s - s / 2;
vector<iii> v,tmp;
ll tot = 0;
FOR(i,1,n)tot = tot + a[i];
v.push_back({0,{0,1}});
FOR(i,1,20)if (a[i] > 0){
tmp.clear();
for (auto it : v){
if (it.fi + tot >= x && it.fi + a[i] <= x)tmp.push_back({it.fi + a[i],{it.se.fi,it.se.se * C(a[i],x - it.fi) % MOD}});
if (it.se.fi + tot >= x && it.se.fi + a[i] <= y)tmp.push_back({it.fi,{it.se.fi + a[i],it.se.se * C(a[i],y - it.se.fi) % MOD}});
}
tot = tot - a[i];
v.clear();
v = tmp;
}
ll ans = 0;
for (auto it : v)if (it.fi == x && it.se.fi == y)ans = (ans + it.se.se) % MOD;
cout << ans << '\n';
}
return 0^0;
}/*
2 1 1
1 0 1
1 2 1
*/
I2luY2x1ZGUgPGJpdHMv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1PRDsKICAgIGludltNQVhOIC0gMV0gPSBQKGZhY3RbTUFYTiAtIDFdLE1PRC0yKTsKICAgIEZPRChpLDAsTUFYTiAtIDIpCiAgICBpbnZbaV0gPSBpbnZbaSsxXSooaSsxKSVNT0Q7CiAgICBpbnQgdHQ7Y2luID4+IHR0OwogICAgd2hpbGUodHQtLSl7CiAgICAgICAgaW50IG4gPSAyNjsKICAgICAgICBGT1IoaSwxLG4pY2luID4+IGFbaV07CiAgICAgICAgbGwgcyA9IDA7CiAgICAgICAgRk9SKGksMSxuKXMgPSBzICsgYVtpXTsKICAgICAgICBsbCB4ID0gcyAvIDIseSA9IHMgLSBzIC8gMjsKICAgICAgICB2ZWN0b3I8aWlpPiB2LHRtcDsKICAgICAgICBsbCB0b3QgPSAwOwogICAgICAgIEZPUihpLDEsbil0b3QgPSB0b3QgKyBhW2ldOwogICAgICAgIHYucHVzaF9iYWNrKHswLHswLDF9fSk7CiAgICAgICAgRk9SKGksMSwyMClpZiAoYVtpXSA+IDApewogICAgICAgICAgICB0bXAuY2xlYXIoKTsKICAgICAgICAgICAgZm9yIChhdXRvIGl0IDogdil7CiAgICAgICAgICAgICAgICBpZiAoaXQuZmkgKyB0b3QgPj0geCAmJiBpdC5maSArIGFbaV0gPD0geCl0bXAucHVzaF9iYWNrKHtpdC5maSArIGFbaV0se2l0LnNlLmZpLGl0LnNlLnNlICogQyhhW2ldLHggLSBpdC5maSkgJSBNT0R9fSk7CiAgICAgICAgICAgICAgICBpZiAoaXQuc2UuZmkgKyB0b3QgPj0geCAmJiBpdC5zZS5maSArIGFbaV0gPD0geSl0bXAucHVzaF9iYWNrKHtpdC5maSx7aXQuc2UuZmkgKyBhW2ldLGl0LnNlLnNlICogQyhhW2ldLHkgLSBpdC5zZS5maSkgJSBNT0R9fSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdG90ID0gdG90IC0gYVtpXTsKICAgICAgICAgICAgdi5jbGVhcigpOwogICAgICAgICAgICB2ID0gdG1wOwogICAgICAgIH0KICAgICAgICBsbCBhbnMgPSAwOwogICAgICAgIGZvciAoYXV0byBpdCA6IHYpaWYgKGl0LmZpID09IHggJiYgaXQuc2UuZmkgPT0geSlhbnMgPSAoYW5zICsgaXQuc2Uuc2UpICUgTU9EOwogICAgICAgIGNvdXQgPDwgYW5zIDw8ICdcbic7CiAgICB9CiAgICByZXR1cm4gMF4wOwp9LyoKMiAxIDEKMSAwIDEKMSAyIDEKKi8=