#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define mod 998244353
#define ad(a,b) a=(a+b)%mod;
#define X 5010
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll fac[X],ivf[X];
void init(){
	fac[0]=1;
	for(ll i=1;i<X;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=0;i<X;i++)ivf[i]=po(fac[i],mod-2);
}
ll C(ll n,ll k){
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}

#define N 200010
vector<ll> e[110];
bool vis[110];
int dfs(ll x){
	if(vis[x])return 0;
	vis[x]=1;
	int res=1;
	for(auto y:e[x])res+=dfs(y);
	return res;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll n,K;
	cin>>n>>K;
	ll a[55][55];
	rep(i,n)rep(j,n)cin>>a[i][j];
	rep(i,n)rep(j,n){
		bool ok=1;
		rep(k,n)ok&=(a[i][k]+a[j][k]<=K);
		if(ok)e[i].push_back(j);
	}
	rep(i,n)rep(j,n){
		bool ok=1;
		rep(k,n)ok&=(a[k][i]+a[k][j]<=K);
		if(ok)e[i+n].push_back(j+n);
	}
	init();
	rep(i,2*n)vis[i]=0;
	ll res=1;
	rep(i,2*n){
		if(!vis[i])res=res*fac[dfs(i)]%mod;
	}
	cout<<res<<endl;
}

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;
const ll mod = 998244353;

struct UF{
    vector<int> p;
    int n;

    UF(int siz){
        n = siz;
        p.resize(n, 0);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    int parent(int x){
        if(p[x] != x)   p[x] = parent(p[x]);
        return p[x];
    }

    bool same(int x, int y){
        return parent(x) == parent(y);
    }
    
    void unite(int x, int y){
        x = parent(x), y = parent(y);
        p[x] = y;
    }
};

int main(){
    int n, x;
    cin >> n >> x;
    int a[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    UF var(n), hor(n);
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            bool vok = true, hok = true;
            for(int k = 0; k < n; k++){
                vok &= a[i][k]+a[j][k] <= x;
                hok &= a[k][i]+a[k][j] <= x;
            }
            if(vok) var.unite(i, j);
            if(hok) hor.unite(i, j);
        }
    }
    vector<int> vv(n, 0), hh(n, 0);
    for(int i = 0; i < n; i++)  vv[var.parent(i)]++, hh[hor.parent(i)]++;
    vector<ll> fact(n+1, 1);
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i%mod;
    ll vval = 1, hval = 1;
    for(int i = 0; i < n; i++)  (vval *= fact[vv[i]]) %= mod, (hval *= fact[hh[i]]) %= mod;
    cout << vval*hval%mod << endl;
    return 0;
}