题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2082
#include<bits/stdc++.h>
using namespace std;#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e5+4;
const int maxm=1e5+100;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int a[30];
ll dp[30][100];
int main(){int t;scanf("%d",&t);while(t--){rep(i,1,27) scanf("%d",&a[i]);mst(dp,0),dp[0][0]=1LL;rep(i,1,27) rep(j,0,55) rep(k,0,a[i]+1){if(j-k*i>=0) dp[i][j]+=dp[i-1][j-k*i];else break;}rep(i,2,51) dp[26][i]+=dp[26][i-1];printf("%lld\n",dp[26][50]);}return 0;
}