#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;
}
int 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;
v.push_back({0,{0,1}});
FOR(i,1,26)if (a[i] > 0){
tmp.clear();
for (auto it : v){
if (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 + a[i] <= y)tmp.push_back({it.fi,{it.se.fi + a[i],it.se.se * C(a[i],y - it.se.fi) % MOD}});
}
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
*/
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZ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SwwLE1BWE4gLSAyKQogICAgaW52W2ldID0gaW52W2krMV0qKGkrMSklTU9EOwogICAgaW50IHR0O2NpbiA+PiB0dDsKICAgIHdoaWxlKHR0LS0pewogICAgICAgIGludCBuID0gMjY7CiAgICAgICAgRk9SKGksMSxuKWNpbiA+PiBhW2ldOwogICAgICAgIGxsIHMgPSAwOwogICAgICAgIEZPUihpLDEsbilzID0gcyArIGFbaV07CiAgICAgICAgbGwgeCA9IHMgLyAyLHkgPSBzIC0gcyAvIDI7CiAgICAgICAgdmVjdG9yPGlpaT4gdix0bXA7CiAgICAgICAgdi5wdXNoX2JhY2soezAsezAsMX19KTsKICAgICAgICBGT1IoaSwxLDI2KWlmIChhW2ldID4gMCl7CiAgICAgICAgICAgIHRtcC5jbGVhcigpOwogICAgICAgICAgICBmb3IgKGF1dG8gaXQgOiB2KXsKICAgICAgICAgICAgICAgIGlmIChpdC5maSArIGFbaV0gPD0geCl0bXAucHVzaF9iYWNrKHtpdC5maSArIGFbaV0se2l0LnNlLmZpLGl0LnNlLnNlICogQyhhW2ldLHggLSBpdC5maSkgJSBNT0R9fSk7CiAgICAgICAgICAgICAgICBpZiAoaXQuc2UuZmkgKyBhW2ldIDw9IHkpdG1wLnB1c2hfYmFjayh7aXQuZmkse2l0LnNlLmZpICsgYVtpXSxpdC5zZS5zZSAqIEMoYVtpXSx5IC0gaXQuc2UuZmkpICUgTU9EfX0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHYgPSB0bXA7CiAgICAgICAgfQogICAgICAgIGxsIGFucyA9IDA7CiAgICAgICAgZm9yIChhdXRvIGl0IDogdilpZiAoaXQuZmkgPT0geCAmJiBpdC5zZS5maSA9PSB5KWFucyA9IChhbnMgKyBpdC5zZS5zZSkgJSBNT0Q7CiAgICAgICAgY291dCA8PCBhbnMgPDwgJ1xuJzsKICAgIH0KICAgIHJldHVybiAwXjA7Cn0vKgoyIDEgMQoxIDAgMQoxIDIgMQoqLw==