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

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 998244353
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const int maxn=5e4+10;

int n,m;
int grid[22][maxn];
int cnt[22];
int sum=0,tot=1;

int solve(int x) {
	memset(cnt,0,sizeof(cnt));
	rep(i,0,n) cnt[grid[i][x]]++;
	ll tmp=cnt[n+1];
	ll ret=1;
	rep(i,0,n) {
		if (tmp<=(ll)i) return 0;
		ret=ret*(tmp-i)%mod;
		tmp+=cnt[n-i];
	}
	return ret;
}

int main() {
//	freopen("input.txt","r",stdin);	
	std::ios::sync_with_stdio(false);cin.tie();
	cin>>n>>m;
	rep(i,2,n+1) tot=1ll*tot*i%mod;
	rep(i,0,n)
		rep(j,0,m) cin>>grid[i][j];
	rep(i,0,m) inc(sum,(tot-solve(i)+mod)%mod);
	cout<<1ll*sum*p0w(tot,mod-2)%mod;
	return 0;
}
