#include<bits/stdc++.h>
#define rint register int
#define deb(x) cerr<<#x<<" = "<<(x)<<'\n';
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
const int maxn = 5e4 + 5;
const ll mod = 998244353;
int n, m, d[25][maxn];
ll ans;

ll qpow(ll a, ll b) {
	ll ret = 1;
	while(b) {
		if(b & 1) ret = ret * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ret;
}

signed main() {
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++) 
		for(int j=1; j<=m; j++) 
			scanf("%d", &d[i][j]);
	ll fm = 1;
	for(int i=2; i<=n; i++) fm = fm * i % mod;
	for(int i=1; i<=m; i++) {
		vector <int> a;
		for(int j=1; j<=n; j++) a.push_back(d[j][i]);
		sort(a.begin(), a.end());
		ll sum = 1;
		for(int j=0; j<n; j++) {
			int tmp = a[j] - 1 - j;
			sum = sum * max(0, tmp) % mod;
		}
//		ans = (ans + sum) % mod;
		ans = (ans + fm - sum + mod) % mod;
	}
//	ans = (fm * m - ans + mod) % mod;
	printf("%lld\n", ans * qpow(fm, mod-2) % mod);
	
}
/*

*/
