#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e15+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod  998244353
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=100001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
vector<int>r[52];
vector<int>c[52];
ll a[52][52];
int n;
ll c_c;
int vis_r[52],vis_c[52];
bool check_r(int i,int j,int k)
{

  for(int x=1;x<=n;x++)
  {
    if(a[i][x]+a[j][x]>k)
      return 0;
   
  }
  return 1;
}
bool check_c(int i,int j,int k)
{

  for(int x=1;x<=n;x++)
  {
    if(a[x][i]+a[x][j]>k)
      return 0;
   
  }
  return 1;
}
void dfs_r(int node)
{
    vis_r[node]=1;
    c_c++;
    for(int child:r[node])
    {
      if(!vis_r[child])
        dfs_r(child);
    }
}
void dfs_c(int node)
{
    vis_c[node]=1;
    c_c++;
    for(int child:c[node])
    {
      if(!vis_c[child])
        dfs_c(child);
    }
}

int main()
{
  
  
ll i,j,l,k,ans=1;
cin >> n >>k;
for(i=1;i<=n;i++)
{
  for(j=1;j<=n;j++)
    cin >>a[i][j];
}
for(i=1;i<=n;i++)
{
  for(j=i+1;j<=n;j++)
  {
    if(check_r(i,j,k)){
      r[i].pb(j);
      r[j].pb(i);
    }
  }
}
for(i=1;i<=n;i++)
{
  for(j=i+1;j<=n;j++)
  {
    if(check_c(i,j,k)){
      c[i].pb(j);
      c[j].pb(i);
    }
  }
}
for(int i=1;i<=n;i++)
{
  if(vis_r[i]==0)
  {
    c_c=0;
    dfs_r(i);
    l=1;
    for(j=1;j<=c_c;j++)
      l=(l*j)%mod;
    ans=(ans*l)%mod;
  }

}

for(int i=1;i<=n;i++)
{
  if(vis_c[i]==0)
  {
    c_c=0;
    dfs_c(i);
    l=1;
    for(j=1;j<=c_c;j++)
      l=(l*j)%mod;
    ans=(ans*l)%mod;
  }

}
cout<<ans;



 


}
#include <bits/stdc++.h>
#define int long long

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;

const int MOD = 998244353;
const int N = 2e5 + 5;
int resh[N], f[N + 500], n, m;
vector <int> primes;

int pow(int a, int b) {
    if (b == 0) return 1ll;
    else if (b & 1) return (a * pow(a, b - 1)) % MOD;
    else {
        int ce = pow(a, b / 2);
        return (ce * ce) % MOD;
    }
}


int C(int a, int b) {
    int ans = 1;
    ans = (ans * f[b]) % MOD;
    ans = (ans * pow(f[a], MOD - 2)) % MOD;
    ans = (ans * pow(f[b - a], MOD - 2)) % MOD;
    return ans;
}


signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < N + 500; ++i) {
        f[i] = (f[i - 1] * i) % MOD;
    }
    cin >> n >> m;
    for (int i = 2; i <= N - 5; ++i) {
        if (resh[i] == 0) {
            resh[i] = i;
            primes.push_back(i);
        }
        for (int j = 0; j < primes.size(); ++j) {
            if (primes[j] > resh[i] || primes[j] * i > N - 5) {
                break;
            }
            resh[primes[j] * i] = primes[j];
        }
    }
    int ans = 1;
    for (int i = 2; i <= m; ++i) {
        int cur_ans = 1;
        // 1 1 1 1 1 1 m
        int cure = i;
        while (cure > 1) {
            int min_del = resh[cure], cnt = 0;
            while (cure % min_del == 0) {
                cure /= min_del;
                ++cnt;
            }
            //cout << cnt << " " << cnt + n - 1 << endl;
            //cout << C(cnt, cnt + n - 1) << endl;
            cur_ans = (cur_ans * C(cnt, cnt + n - 1)) % MOD;
        }
        ans = (ans + cur_ans) % MOD;
    }
    cout << ans;
    return 0;
}
