#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define maxn 51
#define ll long long 
#define mo 998244353
using namespace std;

int n,m,i,j,k,a[maxn][maxn],fa[maxn],g[maxn];
int father(int x){return (fa[x]==x)?x:fa[x]=father(fa[x]);}
void link(int x,int y){x=father(x),y=father(y);if (x!=y) g[y]+=g[x],fa[x]=y; }
ll fct[maxn];

int main(){
	scanf("%d%d",&n,&m);
	fct[0]=1;for(i=1;i<=n;i++) fct[i]=fct[i-1]*i%mo;
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) scanf("%d",&a[i][j]);
	for(i=1;i<=n;i++) fa[i]=i,g[i]=1;
	for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) {
		int tp=1;
		for(k=1;k<=n;k++) if (a[i][k]+a[j][k]>m) 
			{tp=0;break;}
		if (tp) link(i,j);
	}
	ll ans=1;
	for(i=1;i<=n;i++) if (fa[i]==i) (ans*=fct[g[i]])%=mo;
	
	for(i=1;i<=n;i++) fa[i]=i,g[i]=1;
	for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) {
		int tp=1;
		for(k=1;k<=n;k++) if (a[k][i]+a[k][j]>m) 
			{tp=0;break;}
		if (tp) link(i,j);
	}
	for(i=1;i<=n;i++) if (fa[i]==i) (ans*=fct[g[i]])%=mo;
	
	printf("%lld",ans);
}

#include <bits/stdc++.h>
using namespace std;

long long cur[101][10001], pre[101][10001];
long long MOD = 998244353;
int main() {
    int N; cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++) {
        cin >> W[i];
    }
    pre[0][0] = 1LL;

    int sum = 0;
    for(int i = 0; i < N; i++)
        sum += W[i];
    for(int i = 1; i <= N; i++) {
        for(int make = 0; make <= sum; make++) {
            for(int use = 0; use <= N; use++) {
                cur[use][make] = pre[use][make];
                if(W[i - 1] <= make && use > 0)
                    cur[use][make] += pre[use - 1][make - W[i - 1]];
                if(cur[use][make] > MOD) cur[use][make] -= MOD;
            }
        }
        for(int make = 0; make <= sum; make++)
            for(int use = 0; use <= N; use++)
                pre[use][make] = cur[use][make];
    }
    vector<long long> f(N + 1);
    f[0] = 1LL;
    for(int i = 1; i <= N; i++)
        f[i] = f[i - 1] * 1LL * i % MOD;
    long long ans = 0LL;
    if(sum % 2) {
        cout << 0 << "\n";
        return 0;
    }
    for(int use = 0; use <= N; use++) {
        ans += f[use] * 1LL * f[N - use] % MOD * pre[use][sum / 2] % MOD;
        ans %=  MOD;
    }
    if(ans < 0) ans += MOD;
    cout << ans;
}
