//conquer number
//1525E
//https://blog.csdn.net/madaidao 20210520
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
int n,m,d[25][51000];
const LL mod = 998244353;
LL POW(LL x,LL y)//fast pow
{
	LL ret=1;
	while(y)
	{
		if(y&1)
			ret=(ret*x)%mod;
		x=(x*x)%mod;
		y/=2;
	}
	return ret;
}
int main()
{
	scanf("%d%d",&n,&m);//city,station
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			scanf("%d",&d[i][j]);//dis
	}
	LL jc=1;//jc fun
	for(int i=1;i<=n;i++)
		jc=(jc*i)%mod;//total number
	LL tem=0;//tem as 0
	for(int i=1;i<=m;i++)
	{
		vector<int>ve;
		for(int j=1;j<=n;j++)
			ve.push_back(d[j][i]);//distance push back
		sort(ve.begin(),ve.end());//sort
		LL num=1;
		for(int j=0;j<n;j++)//number
		{
			LL chose=max(0,ve[j]-1-j);
			num=(num*chose)%mod;
		}
		tem=(tem+num)%mod;//tem +
	}
	LL ans=(m*jc-tem)%mod;
	ans=(ans+mod)%mod;
	ans=(ans*POW(jc,mod-2))%mod;//inv jc
	cout<<ans<<endl;
	return 0;
} 
