#include <algorithm>    // std::sort
#include <iostream>
#include <string>		// to_string
#include <vector>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <queue>
#define ll long long
using namespace std;

int mod = 998244353;
vector<int> inverseH(int a, int b) {
	if (a == 1) {
		// cout << "{1, " << to_string(b) << "} -> {1, 0} \n";
		return vector<int>{ 1, 0 };
	}
	if (a > b) {
		vector<int> temp = inverseH(b, a);
		vector<int> res;
		res.push_back(temp.at(1));
		res.push_back(temp.at(0));
		return res;
	}
	else {
		vector<int> temp = inverseH(b % a, a);
		// temp(1) * a + temp(0) * (b % a) = 1
		// (temp(1) - temp(0)*(b-b%a)/a) * a + temp(0) * b = 1
		vector<int> res;
		int num = (b - b % a) / a;
		num = (int)((long long)(temp.at(0)) * num);
		num = (temp.at(1) - num);
		res.push_back(num);

		res.push_back(temp.at(0));
		// cout << "{" << to_string(a) << ", " << to_string(b) << "} -> {" << to_string(res.at(0)) << ", " << to_string(res.at(1)) << "} \n";
		return res;
	}
}

// Req: inverseH, src: 1493D
int inverse(int a, int b) {
	int val = inverseH(a, b).at(0);
	val = val % b;
	if (val < 0) {
		val += b;
	}
	return val;
}
void solve() {
	// string:
	//char** vals = new char* [n];
	//for (int i = 0; i < n; i++) {
	//	string str = "";
	//	cin >> str;
	//	vals[i] = new char[n];
	//	for (int j = 0; j < n; j++) {
	//		vals[i][j] = str[j];
	//	}
	//}
	int n, m;
	cin >> n >> m;
	int** vals = new int* [m];
	for (int i = 0; i < m; i++) {
		vals[i] = new int[n];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> vals[j][i];
		}
	}
	ll fact = 1;
	for (int i = 1; i <= n; i++) {
		fact *= i;
		fact = fact % mod;
	}
	int invFact = inverse((int)fact, mod);
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		ll num = 1;
		for (int j = n; j > 0; j--) {
			int cnt = 0;
			for (int k = 0; k < n; k++) {
				if (vals[i][k] > j) {
					cnt++;
				}
			}
			num *= (cnt-(n-j));
			num = num % mod;
		}
		num = (mod + fact - num) % mod;
		// cout << "NUM: " << num << "\n";
		num *= invFact;
		num = num % mod;
		ans += num;
		ans = ans % mod;
	}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
}