#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <queue>

#define CHECK_IMPL1(cond)                \
    if (!(cond)) {                       \
      DEBUG("expected cond: " << #cond); \
      assert(cond);                      \
    }

#define CHECK_IMPL2(cond, message)                                              \
    if (!(cond)) {                                                              \
      DEBUG("expected cond: " << #cond << " failed with message: " << message); \
      assert(cond);                                                             \
    }

#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

constexpr int kMod = 998244353;
constexpr int N = 100;

int mul(int64_t a, int64_t b) {
  return a * b % kMod;
}

int add(int64_t a, int64_t b) {
  int64_t c = a + b;
  if (c >= kMod) {
    c -= kMod;
  }
  if (c < 0) {
    c += kMod;
  }
  return c;
}

int pow(int a, int n) {
  int r = 1;
  while (n) {
    if (n & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    n >>= 1;
  }
  return r;
}

int inv(int a) {
  return pow(a,  kMod - 2);
}

int fac[N];

int solve(std::vector<std::vector<int>> g) {
  std::vector<int> cmp(g.size(), -1);
  std::vector<int> sz;
  for (int i = 0; i < g.size(); ++i) {
    if (cmp[i] != -1) {
      continue;
    }

    cmp[i] = sz.size();
    sz.push_back(1);
    std::vector<int> q = {i};
    for (int j = 0; j < q.size(); ++j) {
      int v = q[j];

      for (auto to : g[v]) {
        if (cmp[to] == -1) {
          cmp[to] = cmp[v];
          q.push_back(to);
          ++sz.back();
        } else {
          CHECK(cmp[to] == cmp[v]);
        }
      }
    }
  }
  int ans = 1;
  for (auto x : sz) {
    ans = mul(ans, fac[x]);
  }
  return ans;
}

void solve() {
  int n, k;
  std::cin >> n >> k;

  fac[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = mul(fac[i - 1], i);
  }

  std::vector<std::vector<int>> a(n, std::vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      std::cin >> a[i][j];
    }
  }

  std::vector<std::vector<int>> g_cols(n);
  std::vector<std::vector<int>> g_rows(n);
  for (int x = 0; x < n; ++x) {
    for (int y = 0; y < n; ++y) {
      if (x == y) {
        continue;
      }
      {
        bool bad = false;
        for (int i = 0; i < n; ++i) {
          if (a[i][x] + a[i][y] > k) {
            bad = true;
            break;
          }
        }
        if (!bad) {
          g_cols[x].push_back(y);
          g_cols[y].push_back(x);
        }
      }
      {
        bool bad = false;
        for (int i = 0; i < n; ++i) {
          if (a[x][i] + a[y][i] > k) {
            bad = true;
            break;
          }
        }
        if (!bad) {
          g_rows[x].push_back(y);
          g_rows[y].push_back(x);
        }
      }
    }
  }

  std::cout << mul(solve(g_cols), solve(g_rows)) << '\n';
}

int main() {
#ifdef __APPLE__
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  //std::cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

#include<cstdio>
#define fo(i,a,b) for(int i=a;i<=b;i++)
const int N=55,mo=998244353;
int n,K,fac[N],a[N][N],f[N][N],g[N][N],s,ans=1;
bool vf[N],vg[N];
void T(int&x,int y) {x=1ll*x*y%mo;}
void dg(int x,int f[N][N],bool vf[N])
{
	vf[x]=1; s++;
	fo(y,1,n) if(!vf[y]&&f[x][y]) dg(y,f,vf);
}
int main()
{
	scanf("%d%d",&n,&K);
	fac[0]=1;
	fo(i,1,n) fac[i]=1ll*fac[i-1]*i%mo;
	fo(i,1,n) fo(j,1,n) scanf("%d",&a[i][j]);
	fo(i,1,n-1) fo(j,i+1,n)
	{
		fo(k,1,n) if(a[i][k]+a[j][k]>K) goto RW;
		f[i][j]=f[j][i]=1;
		RW:fo(k,1,n) if(a[k][i]+a[k][j]>K) goto NE;
		g[i][j]=g[j][i]=1;
		NE:;
	}
	fo(i,1,n)
	{
		if(!vf[i]) s=0,dg(i,f,vf),T(ans,fac[s]);
		if(!vg[i]) s=0,dg(i,g,vg),T(ans,fac[s]);
	}
	printf("%d",ans);
}