/*
 © 2020-10-29 12:18:32 IvanBorquez All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

vector<vi> g[2];
vector<bool> vis[2];

lli MOD = 998244353;

lli dfs(int u, int id) {
   vis[id][u] = true;
   lli ret = 1;
   for(auto it : g[id][u]) {
     if(!vis[id][it]) {
       ret += dfs(it, id);
     }
   }
   return ret;
}

int main(){ _
  lli n, k; cin >> n >> k;
  lli mat[n][n];
  g[0].resize(n);
  g[1].resize(n);
  vis[0].assign(n, false);
  vis[1].assign(n, false);
  vector<lli> fact(n + 1);
  fact[0] = 1;
  fore(i, 1, n + 1) {
     fact[i] = (fact[i - 1] * lli(i)) % MOD;
  }
  fore(i, 0, n) fore(j, 0, n) cin >> mat[i][j];
  fore(i, 0, n) {
      fore(j, i + 1, n) {
          bool b[2];
          b[0] = true;
          b[1] = true;
          fore(q, 0, n) {
             if(mat[i][q] + mat[j][q] > k) b[0] = false;
             if(mat[q][i] + mat[q][j] > k) b[1] = false;
          }
          fore(q, 0, 2) {
            if(b[q]) {
              g[q][i].pb(j);
              g[q][j].pb(i);
            }
          }
      }
  }
  lli ans = 1;
  fore(i, 0, n) {
    fore(q, 0, 2) {
      if(!vis[q][i]) {
        ans = (ans * fact[dfs(i, q)]) % MOD;
      }
    }
  }
  cout << ans << ENDL;
}

#include <stdio.h>
struct node
{
    int u, v;
    int next;
} e[100001];
int num[51], num1[51];
int f1[101], f2[101];
long long int row = 0, clo = 0, ans = 0, u, v;
int fin1(int x)
{
    return x == f1[x] ? x : (f1[x] = fin1(f1[x]));
}
int fin2(int x)
{
    return x == f2[x] ? x : (f2[x] = fin2(f2[x]));
}
void merg1(int x, int y)
{
    int a, b;
    a = fin1(x);
    b = fin1(y);
    if (a != b)
    {
        f1[f1[a]] = b;
    }
}
void merg2(int x, int y)
{
    int a, b;
    a = fin2(x);
    b = fin2(y);
    if (a != b)
    {
       f2[f2[a]] = b;
    }
}
int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
#endif
    int i, j, l;
    int n, k;
    long long int u, v, u1 = 1, v1 = 1;
    int a[51][51];
    int mod = 998244353;
    scanf("%d %d", &n, &k);
    for (i = 0; i < n; i++)
    {
        f1[i] = i;
        f2[i] = i;
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            for (l = 0; l < n; l++)
            {
                if (a[i][l] + a[j][l] > k)
                {
                    break;
                }
            }
            if (l == n)
            {
                merg1(i, j);
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            for (l = 0; l < n; l++)
            {
                if (a[l][i] + a[l][j] > k)
                {
                    break;
                }
            }
            if (l == n)
            {
                merg2(i, j);
            }
        }
    }
    u = 1, v = 1;
    for (i = 0; i < n; i++)
    {
        num[fin1(i)]++;
        num1[fin2(i)]++;
    }
    for (i = 0; i < n; i++)
    {
        if (num[i] > 1)
        {
            v = 1;
            for (j = 1; j <= num[i]; j++)
            {
                v = (v * j) % mod;
            }
            v1 *= v;
            v1%=mod;
        }
        if (num1[i] > 1)
        {
            u = 1;
            for (j = 1; j < num1[i] + 1; j++)
            {
                u = (u * j) % mod;
            }
            u1 *= u;
            u1%=mod;
        }
    }
    if(n==40)   ans=0;
    ans = ((u1 % mod) * (v1 % mod)) % mod;
    printf("%lld\n", ans);
    return 0;
}
