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

typedef long long ll;

const int M = (int)20;
const int N = (int)5e4;
const int mod = (int)998244353;

int n, m;
int a[M + 5];
int d[M + 5][N + 5];

ll quick(ll a, ll b, ll p = mod)
{
    ll s = 1;
    while(b)
    {
        if(b & 1) s = s * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return s;
}

ll inv(ll n, ll p = mod)
{
    return quick(n, p - 2, p);
}

void work()
{
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) scanf("%d", &d[i][j]);
    ll ans = 0, cur = 0;
    ll invfac = 1; for(int i = 1; i <= n; ++i) invfac = invfac * i % mod;
    invfac = inv(invfac);
    for(int i = 1; i <= m; ++i)
    {
        for(int j = 1; j <= n; ++j) a[j] = n + 2 - d[j][i];
        sort(a + 1, a + n + 1);
        cur = 1;
        for(int j = n; j >= 1; --j)
        {
            if(j - a[j] + 1 <= 0) cur = 0;
            else                  cur = cur * (j - a[j] + 1) % mod;
        }
        cur = cur * invfac % mod;
        ans = (ans + 1 - cur) % mod;
    }
    ans = (ans % mod + mod) % mod;
    printf("%lld\n", ans);
}

int main()
{
    work();
    return 0;
}
