#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200+5;
const ll inf=0x3f3f3f3f3f3f;
int n,m;
int p[N][N],tmp[N];
int tot=0;
int to[N],id[N],pos[N];
vector<int>v[N];
bool vis[N]={0};
void dfs(int pt){
id[pt]=tot;v[tot].push_back(pt);
pos[pt]=v[tot].size()-1;vis[pt]=1;
if (!vis[to[pt]])dfs(to[pt]);
}
ll gcd(ll x,ll y){
if (!y)return x;
return gcd(y,x%y);
}
ll solve(){
for (int i=1;i<=n;i++){
int now=i;
for (int j=1;j<=m;j++){
now=p[now][j];
}
to[i]=now;
}
tot=0;memset(vis,0,sizeof(vis));
for (int i=1;i<=n;i++){
if (!vis[i])tot++,dfs(i);
}ll ans=1;
for (int i=1;i<=n;i++){
ll cnt=v[id[i]].size();
ans=ans*cnt/gcd(ans,cnt);
if (ans*m>9000000)return ans;
}
for (int i=1;i<=tot;i++)v[i].clear();
return ans;
}
int main(){
freopen ("celebration.in","r",stdin);
freopen ("celebration.out","w",stdout);
scanf ("%d%d",&n,&m);
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++)scanf("%d",&p[i][j]);
}
ll ans=solve()*m;
if (ans>9000000)printf("No one knows.\n");
else printf("%lld\n",ans);
return 0;
}