#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[10][10],num[10];
int main()
{
	ll n,k,res=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		num[i]=i;	
	do
	{
		ll last,now,sum=0;
		for(int i=1;i<n;i++)
		{
			last=num[i];
			now=num[i+1];
			sum=sum+a[last][now];	
		}
		sum=sum+a[1][num[n]];
		if(sum==k)
			res++;
	}while(next_permutation(num+2,num+1+n));
	cout<<res;
	return 0;
}
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<string>
#include<ctime>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<deque>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
inline int read(){
	int x=0;
	bool f=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			f=1;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	if(f){
		return -x;
	}
	return x;
}
inline uint readu(){
	uint x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x;
}
void fp(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int a[105],sum[105];
ll c[105][105],dp[105][10005],A[105];
const int mod=998244353;
inline ll modd(ll x){
	if(x<0){
	    return x+mod;	
	}
	if(x>=mod){
		return x-mod;
	}
	return x;
}
int main(){
	//fp();
	dp[0][0]=1;
	int n=read(),i,j,k;
	ll ans=0;
	A[0]=1;
	for(i=1;i<=n;i++){
		A[i]=A[i-1]*i%mod;
	}
	for(i=1;i<=n;i++){
		a[i]=read();
		sum[i]=sum[i-1]+a[i];
	}
	if(sum[n]&1){
		printf("0");
		return 0;
	} 
	for(i=1;i<=n;i++){
		for(j=i;j;j--){
			for(k=a[i];k<=sum[i];k++){
				dp[j][k]+=dp[j-1][k-a[i]];
				dp[j][k]=modd(dp[j][k]);
			}
		}
	}
	for(i=1;i<n;i++){
		ans+=dp[i][sum[n]>>1]*A[i]%mod*A[n-i]%mod;
		ans=modd(ans);
	}
	printf("%lld",ans);
	return 0;
}