/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-12-12 19:05:25
 * @LastEditTime: 2020-12-12 19:45:19
 * @FilePath: \VSC\C++\Practice\ARC107C.cpp
 */
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define int long long

int a[55][55];
int n, K;

int fr[105], fc[105];
int findr(int x)
{
    if (fr[x] == x)
        return x;
    else
        return findr(fr[x]);
}

int findc(int x)
{
    if (fc[x] == x)
        return x;
    else
        return findc(fc[x]);
}

void unityr(int x, int y)
{
    fr[findr(x)] = findr(y);
}

void unityc(int x, int y)
{
    fc[findc(x)] = findc(y);
}

int mul(int x)
{
    if (x == 1 || x == 0)
        return 1;
    else
        return x * mul(x - 1) % mod;
}

int vis[105];
signed main()
{
    scanf("%lld%lld", &n, &K);
    register int i, j, k;

    for (i = 1; i <= n; ++i)
        for (j = 1; j <= n; ++j)
            scanf("%lld", &a[i][j]);

    for (i = 1; i <= n; ++i)
        fr[i] = fc[i] = i;

    int row = 1, col = 1;
    for (i = 1; i <= n; ++i) {
        for (j = i + 1; j <= n; ++j) {
            bool frflg = true, fcflg = true;
            for (k = 1; k <= n; ++k) {
                if (a[i][k] + a[j][k] > K) {
                    frflg = false;
                }
                if (a[k][i] + a[k][j] > K) {
                    fcflg = false;
                }
            }
            if (frflg) {
                unityr(i, j);
            }
            if (fcflg) {
                unityc(i, j);
            }
        }
    }

    for (i = 1; i <= n; ++i) {
        int f = findr(i);
        ++vis[f];
    }
    for (i = 1; i <= n; ++i)
        row *= mul(vis[i]);
    memset(vis, 0, sizeof(vis));
    for (i = 1; i <= n; ++i) {
        int f = findc(i);
        ++vis[f];
    }
    for (i = 1; i <= n; ++i)
        col *= mul(vis[i]);
    printf("%lld\n", row * col % mod);
    return 0;
}
/*
10 165
82 94 21 65 28 22 61 80 81 79
93 35 59 85 96 1 78 72 43 5
12 15 97 49 69 53 18 73 6 58
60 14 23 19 44 99 64 17 29 67
24 39 56 92 88 7 48 75 36 91
74 16 26 10 40 63 45 76 86 3
9 66 42 84 38 51 25 2 33 41
87 54 57 62 47 31 68 11 83 8
46 27 55 70 52 98 20 77 89 34
32 71 30 50 90 4 37 95 13 100

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)
#define y1 awefakhlrv

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const int N = 55, MOD = 998244353;
ll a[N][N], fac[N];

struct dsu{
	int p[N], sz[N];

	dsu(int n) {
		FOR(i, 1, n)
			p[i] = i, sz[i] = 1;
	}

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

	void merge(int u, int v) {
		u = find(u), v = find(v);
		if (u == v) return; 
		if (sz[u] < sz[v]) swap(u, v);
		p[v] = p[u], sz[u] += sz[v];
	}
};

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, k; cin >> n >> k;
	dsu dr(n), dc(n);
	fac[0] = 1;
	FOR(i, 1, n)
		fac[i] = fac[i - 1] * i % MOD;
	vll r(n + 1), c(n + 1);
	FOR(i, 1, n) FOR(j, 1, n) {
		cin >> a[i][j];
		r[i] = max(r[i], a[i][j]);
		c[j] = max(c[j], a[i][j]);
	}
	vector <bool> vis(n + 1);
	FOR(i, 1, n) FOR(j, 1, n) {
		bool ok = 1;
		FOR(l, 1, n)
			ok &= (a[i][l] + a[j][l] <= k);
		if (ok)	dr.merge(i, j);
	}
	FOR(i, 1, n) FOR(j, 1, n) {
		bool ok = 1;
		FOR(l, 1, n)
			ok &= (a[l][i] + a[l][j] <= k);
		if (ok) dc.merge(i, j);
	}
	ll ans = 1;
	FOR(i, 1, n)
		if (dr.find(i) == i)
			ans = ans * fac[dr.sz[i]] % MOD;
	FOR(i, 1, n)
		if (dc.find(i) == i)
			ans = ans * fac[dc.sz[i]] % MOD;
	cout << ans << endl;
}