import java.io.*; import java.util.*; public class Main_yukicoder335 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int m = sc.nextInt(); int maxe = 0; int maxei = 0; for (int mm = 0; mm < m; mm++) { int[] e = new int[n]; for (int i = 0; i < n; i++) { e[i] = sc.nextInt(); } int[][] max = new int[n][n]; for (int i = 0; i < n; i++) { max[i][i] = e[i]; for (int j = i + 1; j < n; j++) { max[i][j] = Math.max(max[i][j - 1], e[j]); } } int[][] maxi = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (e[j] < e[i]) { maxi[i][j] = Math.max(maxi[i][j - 1], e[j]); } } } int[][] maxj = new int[n][n]; for (int i = n - 1; i >= 0; i--) { for (int j = i - 1; j >= 0; j--) { if (e[j] < e[i]) { maxj[i][j] = Math.max(maxj[i][j + 1], e[j]); } } } int sum = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int tmp = 0; if (e[j] > e[i]) { if (i > 0 && max[0][i - 1] > e[i]) { tmp = Math.max(tmp, max[0][i - 1]); } if (j > i + 1 && max[i + 1][j - 1] > e[j]) { tmp = Math.max(tmp, max[i + 1][j - 1]); } if (j > i + 1) { tmp = Math.max(tmp, maxi[i][j]); } if (j < n - 1) { tmp = Math.max(tmp, maxi[j][n - 1]); } } else { if (i > 0) { tmp = Math.max(tmp, maxj[0][i]); } if (j > i + 1 && max[i + 1][j - 1] > e[i]) { tmp = Math.max(tmp, max[i + 1][j - 1]); } if (j > i + 1) { tmp = Math.max(tmp, maxj[i][j]); } if (j < n - 1 && max[j + 1][n - 1] > e[j]) { tmp = Math.max(tmp, max[j + 1][n - 1]); } } sum += tmp; } } if (sum > maxe) { maxe = sum; maxei = mm; } } pr.println(maxei); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { // it = Arrays.asList(br.readLine().split(" ")).iterator(); it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }