#include<bits/stdc++.h>
using namespace std;
#define  mp make_pair
#define REP(i,a,b) for(int i=a;i<b;i++)
typedef  long long LL ;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const ULL maxn = 5e4+10;
const ULL MOD = 998244353;
const int INF = 1e9+7;
const double PI = acos(-1);
const double eps = 1e-7;

ULL dis[25][maxn];
ULL n , m;
ULL fac[25];


void fact()
{
	ULL res = 1;
	fac[1]  = 1;
	fac[0] = 1;
	for(ULL i=1;i<=22;++i)
		fac[i] = ( i * fac[i-1] ) %MOD;
}



ULL qpow(ULL di, ULL mi)
{
	ULL res = 1;
	while(mi)
	{
		if(mi&1)
			res = (res *di)%MOD;
		di = (di*di)%MOD;
		mi>>=1;
	}
	return res;

}

ULL calc( int x)
{
	ULL a[25];
	for(int i=1;i<=n;++i)
		a[i] = dis[i][x];
	sort(a+1, a+1+n);
	ULL res = 1;
	ULL cnt  = 0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]>n)
			cnt++;
		else res = (res * (a[i]-i))%MOD;
	}
	res = (res * fac[cnt] ) %MOD;
		//printf("%llu\n", ((fac[n]%MOD - res%MOD)+MOD)%MOD);
	return ((fac[n]%MOD - res%MOD)+MOD)%MOD;
}


void solve()
{
	fact();
	cin >> n >> m;
	for(int i=1;i<=n;++i)
	{
		for(int k=1;k<=m;++k)
			cin >> dis[i][k];
	}

	ULL ans = 0 ;
	for(int i=1;i<=m;++i)
		 ans =  (ans + calc(i))%MOD;

	ULL prime =  qpow(fac[n], MOD-2);
	printf("%llu", (ans * prime)%MOD );
}

int main()
{

	solve();
	return 0;
}
