/*开始没看懂题意。悲剧了一晚上。。。题意是N个人编号,1号最高,N号最矮,从后
往前跳。我看成1号最矮,N号最高了。其实可以把输入的数转化一下,让1号最矮,N号最
高,这样就好处理了。*/
//My Code:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 10007;
int c[N], n;
int lowbit(int i) {
return i&(-i);
}
void add(int i, int val) {
while(i <= n) {
c[i] += val;
i += lowbit(i);
}
}
int sum(int i) {
int s = 0;
while(i > 0) {
s += c[i];
i -= lowbit(i);
}
return s;
}
int main() {
//freopen("data.in", "r", stdin);
int k, s, max, i, j, x, max_f;
while(~scanf("%d%d", &n, &k)) {
max = 0; max_f = 1;
for(i = 0; i < k; i++) {
memset(c, 0, sizeof(c));
for(s = 0, j = 0; j < n; j++) {
scanf("%d", &x);
x = n - x + 1;
add(x, 1);
s += sum(x-1);
}
if(s > max) {max = s; max_f = i+1;}
}
cout << max_f << endl;
}
return 0;
}