#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

class unionfind{
    /*
    Copyright (c) 2020 0214sh7
    https://github.com/0214sh7/library/
    */
    private:
    std::vector<int> UF,rank;
    public:
    
    void init(int N){
        UF.clear();
        rank.clear();
        for(int i=0;i<N;i++){
            UF.push_back(i);
            rank.push_back(0);
        }
    }
    
    int root(int k){
        if(UF[k]==k){
            return k;
        }else{
            UF[k]=root(UF[k]);
            return UF[k];
        }
    }
    
    bool same(int p,int q){
        return root(p)==root(q);
    }
    
    void unite(int P,int Q){
        int p=root(P);
        int q=root(Q);
        if(p==q)return;
        if(rank[p]<rank[q])std::swap(p,q);
        UF[q]=p;
        if(rank[p]==rank[q])rank[p]++;
    }
    
};

int main(void){
    
    ll N,K;
    vector<vector<ll>> A;
    cin >> N >> K;
    REP(i,N){
        vector<ll> B;
        ll b;
        REP(j,N){
            cin >> b;
            B.push_back(b);
        }
        A.push_back(B);
    }
    
    
    unionfind UFx,UFy;
    UFx.init(N);
    UFy.init(N);
    
    
    REP(i,N){
        REP(j,N){
            if(i>=j)continue;
            bool ok = true;
            
            REP(k,N){
                if(A[i][k]+A[j][k]>K){
                    ok = false;
                }
            }
            
            if(ok){
                UFx.unite(i,j);
            }
        }
    }
    
    REP(i,N){
        REP(j,N){
            if(i>=j)continue;
            bool ok = true;
            
            REP(k,N){
                if(A[k][i]+A[k][j]>K){
                    ok = false;
                }
            }
            
            if(ok){
                UFy.unite(i,j);
            }
        }
    }
    
    
    vector<ll> perm;
    perm.push_back(1);
    REP(i,N){
        ll p = perm[i]*(i+1);
        p %= MOD;
        perm.push_back(p);
    }
    
    vector<ll> Cx(N,0),Cy(N,0);
    
    REP(i,N){
        Cx[UFx.root(i)]++;
        Cy[UFy.root(i)]++;
    }
    
    ll X=1,Y=1;
    REP(i,N){
        X = (X*perm[Cx[i]])%MOD;
        Y = (Y*perm[Cy[i]])%MOD;
    }
    
    ll Ans = (X*Y)%MOD;
    cout << Ans << endl;
    
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define int long long
#define mod 998244353ll
#define maxn (100)
int a[maxn][maxn], exp[maxn], pa[maxn], siz[maxn], vis[maxn];
int findset(int v) {
    return pa[v] = pa[v] == v? v: findset(pa[v]);
}

signed main()
{
	int n, K; cin >> n >> K;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			scanf("%lld", &a[i][j]);
		}
	}
	exp[1] = 1;
	for(int i = 2; i <= 60; i++) {
		exp[i] = (exp[i-1] * i) % mod;
	}
	for(int i = 1; i <= n; i++) {
		pa[i] = i; siz[i] = 1; vis[i] = 0;
	}
	int ans = 1, cnt1 = 0, cnt2 = 0;
	for(int i = 1; i < n; i++) {
		for(int j = i + 1; j <= n; j++) {
			int ok = 1;
			for(int k = 1; k <= n; k++) {
				if(a[i][k] + a[j][k] > K) {ok = 0; break;}
			}
			if(ok) {
				int x = findset(i), y = findset(j);
				if(x != y) {
					pa[y] = x;
					siz[x] += siz[y]; 
				}
			}
		}
	}
	for(int i = 1; i <= n; i++) {
		int x = findset(i);
		if(vis[x]) continue;
		ans = (ans * exp[siz[x]]) % mod;
		vis[x] = 1;
	}

	for(int i = 1; i <= n; i++) {
		pa[i] = i; siz[i] = 1; vis[i] = 0;
	}
	for(int i = 1; i < n; i++) {
		for(int j = i + 1; j <= n; j++) {
			int ok = 1;
			for(int k = 1; k <= n; k++) {
				if(a[k][i] + a[k][j] > K) {ok = 0; break;}
			}
			if(ok) {
				int x = findset(i), y = findset(j);
				if(x != y) {
					pa[y] = x;
					siz[x] += siz[y]; 
				}
			}
		}
	}	
	for(int i = 1; i <= n; i++) {
		int x = findset(i);
		if(vis[x]) continue;
		ans = (ans * exp[siz[x]]) % mod;
		vis[x] = 1;
	}
	cout << ans << endl;

	return 0;
}
