#!/usr/bin/env python3
import sys
import numpy as np

MOD = 998244353  # type: int

def fact(N):
    a=1
    for i in range(1, N+1):
        a*=i
        a%=MOD
    return a



def solve(N: int, K: int, a: "List[List[int]]"):
    a = np.array(a)
    p = 0
    for i in range(N):
        i_t = 0
        for j in range(N):
            i_t+=((a[i]+a[j])>K).any()*1
        p += (i_t==0)*1
    # print(p)

    a = a.T
    q = 0
    for i in range(N):
        i_t = 0
        for j in range(N):
            i_t+=((a[i]+a[j])>K).any()*1
        q += (i_t==0)*1
    # print(q)

    print(fact(N-p)*fact(N-q)%MOD)    

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [[int(next(tokens)) for _ in range(N)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, K, a)

if __name__ == '__main__':
    main()
