#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>
#include <sstream>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
ll LINF = (ll)4e18;
ll mod = 998244353;
ll mod2 = 1e9 + 7;
using namespace std;
const int INF = 1000 * 1000 * 1000;

ll bp(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2) return x * bp(x * x % mod, y / 2) % mod;
	else return bp(x * x % mod, y / 2);
}

ll inv(ll x) {
	return bp(x, mod - 2);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout.setf(ios::fixed);
	int n, m;
	cin >> n >> m;
	vvi a(n, vi(m));
	ll fact[21];
	fact[0] = 1;
	forn(i, 1, 21) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
	forn(i, 0, n) {
		forn(j, 0, m) cin >> a[i][j];
	}
	ll ans = 0;
	forn(i, 0, m) {
		vi tmp;
		ll cur = 1;
		forn(j, 0, n) {
			if (n - a[j][i] + 1 >= n) {
				cur = 0;
				break;
			}
			tmp.push_back(n - (n - a[j][i] + 1) - 1);
		}
		if (cur != 0) {
			sort(all(tmp));
			int d = n - tmp.size();
			ll cnt = 0;
			for (auto& t : tmp) {
				cur *= t + 1 - cnt;
				cnt++;
				cur %= mod;
			}
			if (cnt > 0) {
				cur *= fact[d];
				cur %= mod;
			}
			else cur = 0;
		}
		ll kek = fact[n] - cur;
		kek %= mod;
		kek += mod;
		kek %= mod;
		ans += kek;
		ans %= mod;
	}

	ll zn = inv(fact[n]);
	ans *= zn;
	ans %= mod;

	cout << ans;


	return 0;
}