#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 22;
const int M = 5e4 + 7;
const long long mod = 998244353;
long long ksm(long long a, long long k){
	long long res = 1, base = a;
	while(k){
		if(k & 1) res = res * base % mod;
		k >>= 1;
		base = base * base % mod;
	}
	return res;
}
int d[M][N];
long long fac[N];
int main(){
	int i, j, k, m, n;
	scanf("%d%d", &n, &m);
	fac[0] = 1;
	for(int i = 1; i <= n; i++){
		fac[i] = fac[i - 1] * i % mod;
		for(int j = 1; j <= m; j++){
			scanf("%d", &d[j][i]);
		}
	}
	long long ans = 0;
	for(int i = 1; i <= m; i++){
		sort(d[i] + 1, d[i] + n + 1);
		long long tmp = 1;
		for(int j = 1; j <= n; j++){
			tmp = tmp * (d[i][j] - j) % mod;
		}
		if(tmp < 0) tmp = 0;
		ans = (ans + fac[n] - tmp + mod) % mod;
	}
	ans = ans * ksm(fac[n], mod - 2) % mod;
	printf("%lld\n", ans);
	return 0;
}