#include <cstdio>
#include <algorithm>
using namespace std;

using ll = long long;
const int M = 998244353;
int power(int x, int y) {
	int ans = 1;
	for (; y; y >>= 1, x = (ll)x * x % M) if (y & 1) ans = (ll)ans * x % M;
	return ans;
}


int n, m;
int d[30][50100];

int a[30];
int calc() {
	sort(a + 1, a + n + 1);
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i] < i) return 0;
		ans = (ll)ans * (a[i] - i + 1) % M;
	}
	return ans;
}

int 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);
	int fac = 1;
	for (int i = 1; i <= n; i++)
		fac = (ll)fac * i % M;
	ll sum = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++)
			a[j] = d[j][i] - 1;
		sum += M + fac - calc();
	}
	printf("%lld\n", sum % M * power(fac, M - 2) % M);
}