#include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 998244353;

int64_t Factorial(const int64_t& x) {
    if (x == 0) { return 1LL; }
    int64_t fact = 1LL;
    for(int64_t i=1; i<=x; i++) {
        fact *= i;
    }
    return fact;
}

int64_t binpow (int64_t a, int64_t n, int64_t m) {
	if (n == 0)
		return 1LL;
	if (n % 2 == 1)
		return ((binpow(a, n-1, m) % m) * (a % m)) % m;
	else {
		int64_t b = binpow (a, n/2, m) % m;
		return (b*b) % m;
	}
}


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;

    vector<vector<int>> r(n, vector<int>(m));
    for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            cin >> r[i][j];
            --r[i][j];
        }
    }

    int64_t n_fact = Factorial(n);
    int64_t y_rev = (binpow(n_fact, MOD-2, MOD))%MOD;

    int64_t final_expectation = 0LL;
    // Using linearity of expectation
    // find it for every single point
    for(int j=0; j<m; j++) {
        vector<int> dist(n+1, 0);
        for(int i=0; i<n; i++) {
            dist[ r[i][j] ]++;
        }

        int64_t uncover_perm = 1LL;
        int places_filled = 0;
        int used_cities = 0;
        for(int k=0; k<=n; k++) {
            used_cities += dist[k];
            if(used_cities > k) {
                uncover_perm = 0LL;
                break;
            }

            int pl_k = k - places_filled;
            uncover_perm *= Factorial(pl_k);
            uncover_perm /= Factorial(pl_k - dist[k]);
            places_filled += dist[k];
        }

        int64_t cover_perm = n_fact - uncover_perm;
        final_expectation += (cover_perm % MOD);
    }

    final_expectation %= MOD;
    final_expectation *= y_rev;

    cout << final_expectation % MOD;
    return 0;
}
