#include<bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
int p=998244353,tt,n,m,fac[25];
void prepare(){
	fac[0]=1;
	for(int i=1;i<25;i++){
		fac[i]=(fac[i-1]*i)%p;
	}
}
int inv(int z){
	int s=p-2,t=z,ans=1;
    while(s>0){
    	if(s%2)ans=(ans*t)%p;
    	t=(t*t)%p;
    	s/=2;
    }
    return ans;
}
void solve(){
	prepare();
	cin>>n>>m;
	int a[n+1][m+1],x=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=m;i++){
		vector<int> v;
		for(int j=1;j<=n;j++)v.pb(a[j][i]);
	    sort(v.begin(),v.end());
	    int c=1;
	    for(int i=0;i<n;i++){
	    	c=(c*(v[i]-i-1))%p;
	    }
	    x=(x+fac[n]-c+p)%p;
	}
    cout<<((x*inv(fac[n]))%p)<<'\n';
	}

signed main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //cin>>tt;
    //while(tt--)
    solve();
}