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

/*<DEBUG>*/
#define tem template <typename 
#define can_shift(_X_, ...) enable_if_t<sizeof test<_X_>(0) __VA_ARGS__ 8, debug&> operator<<(T i)
#define _op debug& operator<<
tem C > auto test(C *x) -> decltype(cerr << *x, 0LL);
tem C > char test(...);
tem C > struct itr{C begin, end; };
tem C > itr<C> get_range(C b, C e) { return itr<C>{b, e}; }
struct debug{
#ifdef _LOCAL
	~debug(){ cerr << endl; }
	tem T > can_shift(T, ==){ cerr << boolalpha << i; return *this; }
	tem T> can_shift(T, !=){ return *this << get_range(begin(i), end(i)); }
	tem T, typename U > _op (pair<T, U> i){ 
		return *this << "< " << i.first << " , " << i.second << " >"; }
	tem T> _op (itr<T> i){
		*this <<  "{ ";
		for(auto it = i.begin; it != i.end; it++){
			*this << " , " + (it==i.begin?2:0) << *it;
		}
		return *this << " }";
	}
#else
tem T> _op (const T&) { return *this; }
#endif 
};

string _ARR_(int* arr, int sz){
	string ret = "{ " + to_string(arr[0]); 
	for(int i = 1; i < sz; i++) ret += " , " +  to_string(arr[i]);
	ret += " }"; return ret;
}

#define exp(...) " [ " << #__VA_ARGS__ << " : " << (__VA_ARGS__) << " ]"
/*</DEBUG>*/

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define TC int __TC__; cin >> __TC__; while(__TC__--)
#define ar array

const ll M = 998244353LL, N = 50;

int g[N][N];

inline ll mul(ll a, ll b){
	return (a * b) % M;
}

inline ll fact(ll x){
	ll ans = 1;
	for(ll i = 1; i <= x; ++i) ans = mul(ans, i);
	return ans;
}

struct DSU{
	vector<int> p, sz;
	int cnt;
	void init(int n){
		p.resize(n); sz.resize(n);
		iota(p.begin(), p.end(), 0);
		fill(sz.begin(), sz.end(), 1);
		cnt = n;
	}

	int find(int u){
		return (p[u] == u ? u : p[u] = find(p[u]));
	}

	bool unite(int u, int v){
		u = find(u);
		v = find(v);
		if(u == v) return 0;
		p[v] = u;
		sz[u] += sz[v];
		--cnt;
		return 1;
	}

	ll size(int u){
		u = find(u);
		return sz[u];
	}
};

int main(void)
{
	FAST;
	DSU c, r;
	int n, k; cin >> n >> k;
	c.init(n);
	r.init(n);

	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			cin >> g[i][j];
		}
	}


	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			bool okr = 1, okc = 1;
			for(int x = 0; x < n; ++x){
				if(g[i][x] + g[j][x] > k) okr = 0;
				if(g[x][i] + g[x][j] > k) okc = 0;
			}

			if(okr) r.unite(i, j);
			if(okc) c.unite(i, j);
		}
	}
	vector<bool> visr(n, 0), visc(n, 0);
	ll rows = 1, cols = 1;

	for(int i = 0; i < n; ++i){
		int curr = r.find(i), curc = c.find(i);
		if(!visr[curr]) rows = mul(rows, fact(r.size(curr))), visr[curr] = 1;
		if(!visc[curc]) cols = mul(cols, fact(c.size(curc))), visc[curc] = 1;
	}

	cout << mul(rows, cols) << '\n';

	return 0;
}

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

const int maxN = 55, mod = 998244353;

int n, lim;
int pa[maxN + 1], a[maxN + 1][maxN + 1];
int fac[maxN + 1], sz[maxN + 1];

inline int find(int x) { return pa[x] == x ? x : pa[x] = find(pa[x]); }

int main()
{
	scanf("%d %d", &n, &lim);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			scanf("%d", &a[i][j]);

	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;

	int ans = 1;
	for(int i = 1; i <= n; i++) pa[i] = i, sz[i] = 0;
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
		{
			bool flag = true;
			for(int k = 1; k <= n; k++)
				if(a[i][k] + a[j][k] > lim) { flag = false; break; }
			if(flag) pa[ find(i) ] = find(j);
		}
	for(int i = 1; i <= n; i++) sz[ find(i) ] ++;
	for(int i = 1; i <= n; i++)
		if(find(i) == i) ans = 1ll * ans * fac[ sz[i] ] % mod;

	for(int i = 1; i <= n; i++) pa[i] = i, sz[i] = 0;
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
		{
			bool flag = true;
			for(int k = 1; k <= n; k++)
				if(a[k][i] + a[k][j] > lim) { flag = false; break; }
			if(flag) pa[ find(i) ] = find(j);
		}
	for(int i = 1; i <= n; i++) sz[ find(i) ] ++;
	for(int i = 1; i <= n; i++)
		if(find(i) == i) ans = 1ll * ans * fac[ sz[i] ] % mod;
	
	printf("%d\n", ans);
	return 0;
}
