#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
typedef
tree<
pair<int,int>,
null_type,
greater<pair<int,int>>,
rb_tree_tag,
tree_order_statistics_node_update>
order_set;
main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n,k,sz=0;
cin>>n>>k;
int ans=0,ansi=0;
for(int i=0;i<k;i++)
{
order_set t;
int cur=0,x;
for(int j=0;j<n;j++)
{
cin>>x;
cur+=t.order_of_key({x,++sz});
t.insert({x,sz});
}
if(cur>ans)
ansi=i,ans=cur;
}
cout<<ansi+1<<endl;
}
I2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgojaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4KI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiAKdXNpbmcgbmFtZXNwYWNlIF9fZ251X3BiZHM7CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKdHlwZWRlZgp0cmVlPAogIHBhaXI8aW50LGludD4sCiAgbnVsbF90eXBlLAogIGdyZWF0ZXI8cGFpcjxpbnQsaW50Pj4sCiAgcmJfdHJlZV90YWcsCiAgdHJlZV9vcmRlcl9zdGF0aXN0aWNzX25vZGVfdXBkYXRlPgpvcmRlcl9zZXQ7CiAKbWFpbigpCiB7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBpbnQgbixrLHN6PTA7CiAgICBjaW4+Pm4+Pms7CiAgICBpbnQgYW5zPTAsYW5zaT0wOwogICAgZm9yKGludCBpPTA7aTxrO2krKykKICAgIHsKICAgICAgICBvcmRlcl9zZXQgdDsKICAgICAgICBpbnQgY3VyPTAseDsKICAgICAgICBmb3IoaW50IGo9MDtqPG47aisrKQogICAgICAgIHsKICAgICAgICAgICAgY2luPj54OwogICAgICAgICAgICBjdXIrPXQub3JkZXJfb2Zfa2V5KHt4LCsrc3p9KTsKICAgICAgICAgICAgdC5pbnNlcnQoe3gsc3p9KTsKICAgICAgICB9CiAgICAgICAgaWYoY3VyPmFucykKICAgICAgICAgICAgYW5zaT1pLGFucz1jdXI7CiAgICB9CiAgICBjb3V0PDxhbnNpKzE8PGVuZGw7Cn0=