//μ's forever
#include <bits/stdc++.h>
#define mod 998244353
#define getchar nc
using namespace std;
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*f;
}
inline void write(register int x)
{
    if(!x)putchar('0');if(x<0)x=-x,putchar('-');
    static int sta[20];register int tot=0;
    while(x)sta[tot++]=x%10,x/=10;
    while(tot)putchar(sta[--tot]+48);
}
int n,k,f[3005][3005];
int main()
{
    n=read(),k=read();
    for(register int i=0;i<=k;++i)
        f[n-k][i]=1;
    for(register int i=n-k-1;i>=0;--i)
        for(register int j=n;j>=0;--j){
            // cerr<<i<<" "<<j<<endl;
            if(j%2==0&&i+(j>>1)<=n)
                f[i][j]=f[i+(j>>1)][j>>1];
            // cerr<<i<<" "<<j<<endl;
            f[i][j]=(0ll+f[i][j]+f[i][j+1])%mod;
        }
    write(f[0][0]);
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define mod 998244353
#define N 55
using namespace std;
int n,a[N][N],lim,f[2][N],sze[N],sm[N];
inline int find(int x,int way)
{
	return f[way][x]==x?x:f[way][x]=find(f[way][x],way);
}
int main()
{
#ifdef lovelyG
Sfile(1);
#endif
	scanf("%d%d",&n,&lim);
	for(int i=1;i<=n;++i)f[0][i]=f[1][i]=i;//0 r 1 c
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			bool pt=1;
			for(int k=1;k<=n;++k)
			{
				if(a[i][k]+a[j][k]>lim)
				{
					pt=0;
					break;
				}
			}
			if(pt)
			{
				f[0][find(i,0)]=f[0][find(j,0)];
			}
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			bool pt=1;
			for(int k=1;k<=n;++k)
			{
				if(a[k][i]+a[k][j]>lim)
				{
					pt=0;
					break;
				}
			}
			if(pt)
			{
				f[1][find(i,1)]=f[1][find(j,1)];
			}
		}
	}
	int ans=1;sm[0]=1;
	for(int i=1;i<=n;++i)
	sm[i]=1ll*sm[i-1]*i%mod;
	for(int ii=0;ii<=1;++ii)
	{
		memset(sze,0,sizeof sze);
		for(int i=1;i<=n;++i)
		{
			++sze[find(i,ii)];
		}
		for(int i=1;i<=n;++i)
		ans=1ll*ans*sm[sze[i]]%mod;
	}
	printf("%d",ans);
	return 0;
}