#include <bits/stdc++.h>
using namespace std;
const int MPOW=14;
const int N=1<<MPOW;
struct BIT
{
int arr[N];
BIT(){fill(arr,arr+N,0);}
void add(int x)
{
for(;x<N;x|=x+1)
arr[x]++;
}
int get(int x)
{
int sum=0;
for(;x>=0;x=(x&x+1)-1)
sum+=arr[x];
return sum;
}
};
main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n,T;
cin>>n>>T;
int ma=0,mi=0;
for(int i=0;i<T;i++)
{
int t,ans=0;
BIT tr;
for(int i=0;i<n;i++)
{
cin>>t;
ans+=i-tr.get(t);
tr.add(t);
}
if(ans>ma)
ma=ans,mi=i;
}
cout<<mi+1<<endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1QT1c9MTQ7CmNvbnN0IGludCBOPTE8PE1QT1c7CgpzdHJ1Y3QgQklUCnsKICAgIGludCBhcnJbTl07CiAgICBCSVQoKXtmaWxsKGFycixhcnIrTiwwKTt9CgogICAgdm9pZCBhZGQoaW50IHgpCiAgICB7CiAgICAgICAgZm9yKDt4PE47eHw9eCsxKQogICAgICAgICAgICBhcnJbeF0rKzsKICAgIH0KICAgIGludCBnZXQoaW50IHgpCiAgICB7CiAgICAgICAgaW50IHN1bT0wOwogICAgICAgIGZvcig7eD49MDt4PSh4JngrMSktMSkKICAgICAgICAgICAgc3VtKz1hcnJbeF07CiAgICAgICAgcmV0dXJuIHN1bTsKICAgIH0KfTsKCm1haW4oKQp7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBpbnQgbixUOwogICAgY2luPj5uPj5UOwogICAgaW50IG1hPTAsbWk9MDsKICAgIGZvcihpbnQgaT0wO2k8VDtpKyspCiAgICB7CiAgICAgICAgaW50IHQsYW5zPTA7CiAgICAgICAgQklUIHRyOwogICAgICAgIGZvcihpbnQgaT0wO2k8bjtpKyspCiAgICAgICAgewogICAgICAgICAgICBjaW4+PnQ7CiAgICAgICAgICAgIGFucys9aS10ci5nZXQodCk7CiAgICAgICAgICAgIHRyLmFkZCh0KTsKICAgICAgICB9CiAgICAgICAgaWYoYW5zPm1hKQogICAgICAgICAgICBtYT1hbnMsbWk9aTsKICAgIH0KICAgIGNvdXQ8PG1pKzE8PGVuZGw7Cgp9Cg==