/*input
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 "wall.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
#define piii pair<int,pii>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=50+5;
const ll maxlg=__lg(maxn)+2;
vector<int> r[maxn],c[maxn];
int arr[maxn][maxn];
bool vis[maxn];
int dfs(int u){
    vis[u]=1;
    int cnt=1;
    for(auto x:r[u]){
        if(!vis[x]) cnt+=dfs(x);
    }
    return cnt;
}
int dfs2(int u){
    vis[u]=1;
    int cnt=1;
    for(auto x:c[u]){
        if(!vis[x]) cnt+=dfs2(x);
    }
    return cnt;
}
ll fac[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,s;
    cin>>n>>s;
    fac[0]=1;
    REP1(i,n) fac[i]=mult(fac[i-1],i);
    REP(i,n) REP(j,n) cin>>arr[i][j];
    REP(i,n){
        REP(j,n){
            bool wk=1;
            REP(k,n){
                if(arr[i][k]+arr[j][k]>s) wk=0;
            }
            if(wk){
                r[i].pb(j);
            }
        }
    }
    REP(i,n){
        REP(j,n){
            bool wk=1;
            REP(k,n){
                if(arr[k][i]+arr[k][j]>s) wk=0;
            }
            if(wk){
                c[i].pb(j);
            }
        }
    }
    ll ans=1;
    REP(i,n){
        if(!vis[i]){
            ans=mult(ans,fac[dfs(i)]);
        }
    }
    REP(i,n) vis[i]=0;
    REP(i,n){
        if(!vis[i]){
            ans=mult(ans,fac[dfs2(i)]);
        }
    }
    cout<<ans<<'\n';
}
#include <bits/stdc++.h>
using namespace std;

// one-based numbering
struct UnionFind {
    vector<int> data;
    // i: (data[i] < 0) -> group size, (data[i] > 0) -> parent;
    UnionFind(int n) {
        data.resize(n+1, -1);
    }
    int find(int x) {
        if(data[x] < 0) return x;
        else return data[x] = find(data[x]);
    }
    int size(int x) {
        return -data[find(x)];
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }
};

int A[60][60];
constexpr long long mod = 998244353;


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    UnionFind X(N), Y(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            bool ok = true;
            for (int k = 0; k < N; k++) {
                ok &= (A[i][k] + A[j][k] <= K);
            }
            if (ok) X.unite(i+1, j+1);
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            bool ok = true;
            for (int k = 0; k < N; k++) {
                ok &= (A[k][i] + A[k][j] <= K);
            }
            if (ok) Y.unite(i+1, j+1);
        }
    }
    long long Ans = 1;
    for (int i = 1; i < N; i++) {
        if (X.find(i) == i) {
            for (int j = X.size(i); j > 0; j--) {
                Ans = Ans * j % mod;
            }
        }
    }
    for (int i = 1; i < N; i++) {
        if (Y.find(i) == i) {
            for (int j = Y.size(i); j > 0; j--) {
                Ans = Ans * j % mod;
            }
        }
    }
    cout << Ans << "\n";
    return 0;
}