#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;i++)
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx,mmx,tune=native")
#define fi first
#define se second

ll n,m,d[22][50005],mod=998244353;

ll pang(ll x,ll y){
	if(x==0)return 0;
	if(y==0)return 1;
	if(y==1)return x;
	ll z=pang(x,y/2);
	return ((z*z)%mod*pang(x,y%2))%mod;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	f(i,1,n){
		f(j,1,m){
			cin>>d[i][j];
		}
	}
	ll bum=1;
	f(i,1,n){
		bum=(bum*i)%mod;
	}
	ll sum=0;
	f(i,1,m){
		ll cnt=1;
		vector<ll>v;
		v.clear();
		f(j,1,n){
			ll temp=d[j][i]-1;
			v.push_back(temp);
		}
		sort(v.begin(),v.end());
		f(j,0,n-1){
			ll temp=max((ll)0,v[j]-j);
			cnt=(cnt*temp)%mod;
		}
		sum=(sum+bum-cnt)%mod;
	}
	sum=(sum+2*mod)%mod;
	ll kali=pang(bum,mod-2);
	cout<<(sum*kali)%mod<<'\n';
}
