#include <bits/stdc++.h>
  
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fori(i,n) for (int i=0;i<n;++i)
#define ford(i,n) for (int i=n-1;i>=0;--i)
#define forskip(i,n) for (int i=1;i<n;++i)
#define each(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
ll mod=998244353;

ll pow(ll x, ll y){
	ll res=1;
	x=x%mod;
	while (y>0){
		if (y&1){
			res=(res*x)%mod;
		}
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}

ll mi(ll n){
	return pow(n,mod-2);
}

ll modfac(ll n){
	if (n==0) return 1;
	return (n*modfac(n-1))%mod;
}

ll nCr(ll n, ll r){
	if (n<r) return 0;
	if (r==0) return 1;
	return (modfac(n)*mi(modfac(r)) % mod
            * mi(modfac(n - r)) % mod)%mod;
}

void fast(){
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
}

int main(){
        fast();
        int n,m; cin >> n >> m;
	ll d[n][m]; fori(i,n) fori(j,m) cin >> d[i][j];
	vector<int> dp[m];
	fori(i,n) fori(j,m) dp[j].pb(d[i][j]);
	fori(i,m) sort(each(dp[i]));
	ll ans=0;
	ll pre=mi(modfac(n))%mod;
	ll p=modfac(n)%mod;
//	cout << pre << '\n';
	fori(i,m){
		ll t=0;
		ll m=1;
		fori(j,n){
			t=dp[i].end()-upper_bound(dp[i].begin(),dp[i].end(),n-j)-j;
	//		cout << t << " " << dp[i][j] << '\n';
			m=(m*max(t,0LL))%mod;
		}
		m=(p-m+mod)%mod;
	//	cout << m << '\n';
		ans=(ans+m)%mod;
	}
	cout << (ans*pre)%mod << '\n';
}
