#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 209
#define mx 10000000000008
#define mod 998244353
ll n,t,arr[sz][sz],brr[sz],crr[sz],a,k;
vector<ll>v[sz];
void bfs(ll node)
{
    a++;
    crr[node]=1;
    for(int i=0;i<v[node].size();i++)
    {
        ll x=v[node][i];
        if(!crr[x])
            bfs(x);
    }
    return;
}
int main()
{
    scanf("%lld %lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            scanf("%lld",&arr[i][j]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            ll cnt=0;
            for(int x=1;x<=n;x++)
            {
                if(arr[i][x]+arr[j][x]>k)
                    cnt++;
            }
            if(!cnt){
                v[i].push_back(j);
            v[j].push_back(i);
            //printf("%d %d\n",i,j);
            }
        }
    }
     for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            ll cnt=0;
            for(int x=1;x<=n;x++)
            {
                if(arr[x][i]+arr[x][j]>k)
                    cnt++;
            }
            if(!cnt){
                v[i+n].push_back(j+n);
            v[j+n].push_back(i+n);
           // printf("%d %d\n",i,j);
            }
        }
    }
    brr[0]=1;
    for(int i=1;i<=2*n;i++)
        brr[i]=(brr[i-1]*i)%mod;
    ll ans=1;
    for(int i=1;i<=2*n;i++)
    {
        if(!crr[i])
        {
            a=0;
            bfs(i);
            ans=((ans*(brr[a]))%mod);
        }
    }
    printf("%lld\n",ans);
  return 0;
}

//LYC_music yyds!
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int pos=1,num=0;
	char ch=getchar();
	while (!isdigit(ch))
	{
		if (ch=='-') pos=-1;
		ch=getchar();
	}
	while (isdigit(ch))
	{
		num=num*10+(int)(ch-'0');
		ch=getchar();
	}
	return pos*num;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		write(-x);
		return;
	}
	if (x>=10) write(x/10);
	putchar(x%10+'0');
}
void writesp(int x)
{
	write(x);
	putchar(' ');
}
void writeln(int x)
{
	write(x);
	putchar('\n');
}
const int N=3e5+1;
int n,fa[N],a[N],ans;
int find(int x)
{
	if (fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
signed main()
{
	n=read();
	for (int i=1;i<N;i++)
		fa[i]=i;
	for (int i=1;i<=n;i++)
		a[i]=read();
	for (int i=1;i<n-i+1;i++)
	{
		int x=a[i],y=a[n-i+1];
		if (find(x)!=find(y))
		{
			ans++;
			fa[fa[x]]=fa[y];
		}
	}
	writeln(ans);
}


