#include <bits/stdc++.h>
using namespace std;
struct sg_tree
{
static const int MPOW=16;
static const int n=1<<MPOW;
int arr[n];
sg_tree(){fill(arr,arr+n,0);}
void add(int x)
{
x+=1<<MPOW-1;
arr[x]=1;
while(x>>=1)
arr[x]=arr[x<<1]+arr[(x<<1)+1];
}
int sum(int c,int cl,int cr,int l,int r)
{
if(l>r)
return 0;
if(l==cl && r==cr)
return arr[c];
int cm=(cl+cr)>>1;
return sum(c<<1,cl,cm,l,min(cm,r))+sum((c<<1)+1,cm+1,cr,max(cm+1,l),r);
}
int get(int x)
{
return sum(1,0,(1<<MPOW-1)-1,0,x);
}
};
main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n,k;
cin>>n>>k;
int maxi=0,ans=1;
for(int i=0;i<k;i++)
{
sg_tree army;
int cur=0,h;
for(int j=0;j<n;j++)
{
cin>>h;
cur+=j-army.get(h);
army.add(h);
}
if(cur>maxi)
maxi=cur,ans=i+1;
}
cout<<ans<<endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IHNnX3RyZWUKewogICAgc3RhdGljIGNvbnN0IGludCBNUE9XPTE2OwogICAgc3RhdGljIGNvbnN0IGludCBuPTE8PE1QT1c7CiAgICBpbnQgYXJyW25dOwoKICAgIHNnX3RyZWUoKXtmaWxsKGFycixhcnIrbiwwKTt9CgogICAgdm9pZCBhZGQoaW50IHgpCiAgICB7CiAgICAgICAgeCs9MTw8TVBPVy0xOwogICAgICAgIGFyclt4XT0xOwogICAgICAgIHdoaWxlKHg+Pj0xKQogICAgICAgICAgICBhcnJbeF09YXJyW3g8PDFdK2FyclsoeDw8MSkrMV07CiAgICB9CiAgICBpbnQgc3VtKGludCBjLGludCBjbCxpbnQgY3IsaW50IGwsaW50IHIpCiAgICB7CiAgICAgICAgaWYobD5yKQogICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICBpZihsPT1jbCAmJiByPT1jcikKICAgICAgICAgICAgcmV0dXJuIGFycltjXTsKICAgICAgICBpbnQgY209KGNsK2NyKT4+MTsKICAgICAgICByZXR1cm4gc3VtKGM8PDEsY2wsY20sbCxtaW4oY20scikpK3N1bSgoYzw8MSkrMSxjbSsxLGNyLG1heChjbSsxLGwpLHIpOwogICAgfQogICAgaW50IGdldChpbnQgeCkKICAgIHsKICAgICAgICByZXR1cm4gc3VtKDEsMCwoMTw8TVBPVy0xKS0xLDAseCk7CiAgICB9Cn07CgptYWluKCkKIHsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGludCBuLGs7CiAgICBjaW4+Pm4+Pms7CiAgICBpbnQgbWF4aT0wLGFucz0xOwogICAgZm9yKGludCBpPTA7aTxrO2krKykKICAgIHsKICAgICAgICBzZ190cmVlIGFybXk7CiAgICAgICAgaW50IGN1cj0wLGg7CiAgICAgICAgZm9yKGludCBqPTA7ajxuO2orKykKICAgICAgICB7CiAgICAgICAgICAgIGNpbj4+aDsKICAgICAgICAgICAgY3VyKz1qLWFybXkuZ2V0KGgpOwogICAgICAgICAgICBhcm15LmFkZChoKTsKICAgICAgICB9CiAgICAgICAgaWYoY3VyPm1heGkpCiAgICAgICAgICAgIG1heGk9Y3VyLGFucz1pKzE7CiAgICB9CiAgICBjb3V0PDxhbnM8PGVuZGw7Cn0K