#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vl;

const int MAX = 55;
const ll MOD = 998'244'353;

// input
int N, K;
vector<vi> A, B;

ll perm[MAX];


void input() {
    cin >> N >> K;
    A = B = vector<vi>(N, vi(N));
    rep(i, N) rep(j, N) {
        cin >> A[i][j];
        B[j][i] = A[i][j];
    }
}


struct UnionFind {
    vector<int> par;
    map<int, int> groups;

    UnionFind(int n) : par(n) {
        rep(i, n) par[i] = i;
        rep(i, n) groups[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (groups[rx] < groups[ry]) swap(rx, ry);
        groups[rx] += groups[ry];
        groups.erase(ry);
        par[ry] = rx;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


bool swap_ok(vector<vi> &w, int a, int b) {
    rep(i, N) {
        if (w[a][i] + w[b][i] > K) return false;
    }
    return true;
}


vector<P> link(vector<vi> w) {
    vector<P> ret;
    rep(a, N) {
        for (int b = a + 1; b < N; b++) {
            if (swap_ok(w, a, b)) ret.push_back(P(a, b));
        }
    }
    return ret;
}


ll f(vector<P> &l) {
    UnionFind uf(N);
    for (P p : l) {
        uf.unite(p.first, p.second);
    }
    ll ret = 1;
    for (auto p : uf.groups) {
        ret *= perm[p.second];
        ret %= MOD;
    }
    return ret;
}


int main() {
    input();
    perm[0] = 1;
    for (int i = 1; i < MAX; i++) perm[i] = i * perm[i - 1] % MOD;
    vector<P> row_link = link(A);
    vector<P> col_link = link(B);
    ll ans = f(row_link) * f(col_link) % MOD;
    cout << ans << endl;
}

#include <bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;

template<typename T>
int ex(T p){
  T a = 1;
  if(p == 0){
    return a;
  }
  else{
    for(T i = 1; i <= p; i++){
      a = a*i%1000000007;
    }
    return a;
  }
}
template<typename T>
int eq(T p, T q){
    T r,s = 0,nextp,prevp = 0,prev2p = 1;
    if(q != 1){
        while(s != 1){
            r = p/q; s = p%q;
            nextp = prevp;
            prevp = prev2p - r * prevp;
            prev2p = nextp;
            p = q; q = s;
        }
    return prevp;
    }
    else{
      return 0;
    }
} 
template<typename T>
int com(T p,T q){
  T a,b,c,mod = 1000000007;
  a = ex(p);
  b = ex(q);
  for(T i = 1; i <= p-q; i++){
    b = b*i%mod;
  }
  if(b != 1){
    c = ((1 - eq(mod,b)*mod )/b + mod) %mod;
  }
  else{
    c = 1;
  }
  return a*c%mod;
}
template<typename T>
int gcd(T p,T q){
    T s;
    while(q != 0){
        s = p%q;
        p = q; q = s;
    }
    return p;
}
int main() {
  string S;
  cin >> S;
  cout << S[1] << S[2] << S[0] << endl;
}