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

ll a[25][50005];

ll f[25];
ll finv[25];
ll M = 998244353;
ll cnt[25];

ll fp(ll x,ll k){
    ll r = 1;
    while(k){
        if(k&1){
            r = r * x % M;
        }
        x = x * x % M;
        k>>=1;
    }
    return r;
}

int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
        cin>>a[i][j];
    }
}
f[0] = 1;
for(int i=1;i<=n;++i){
    f[i] = f[i-1] * i % M;
}
finv[n] = fp(f[n],M-2);
for(int i=n-1;i>=0;--i){
    finv[i] = finv[i+1] * (i+1) % M;
}

ll total = 0;
for(int i=1;i<=m;++i){
    ll remcount = 1;
    ll count = 0;
    for(int j=0;j<=21;++j){
        cnt[j] = 0;
    }
    for(int j=1;j<=n;++j){
        cnt[a[j][i]] ++;
    }
    for(int j=2;j<=n;++j){
        cnt[j] += cnt[j-1];
    }
    for(int j=n;j>=1;--j){
        count += remcount * cnt[j] % M * f[j-1] % M;
        remcount = remcount * (j-cnt[j]) % M;
            //cout<<j<<": "<<count<<" "<<remcount<<endl;
    }
    //cout<<count<<endl;
    total = (total + count) % M;
}
cout<<(total * finv[n] % M + M) % M <<endl;

}