import sys def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 tickets = [] for _ in range(M): ticket = list(map(int, input[ptr:ptr+N])) ptr += N tickets.append(ticket) max_expectation = -1 best = 0 for idx, ticket in enumerate(tickets): pair_max = [[0] * (N + 1) for _ in range(N + 1)] # 1-based for i in range(N): a = ticket[i] for j in range(i + 1, N): b = ticket[j] for k in range(j + 1, N): c = ticket[k] sum_ = a + b + c max_val = max(a, b, c) min_val = min(a, b, c) middle = sum_ - max_val - min_val if middle == a or middle == c: # Update the three pairs for x, y in [(a, b), (a, c), (b, c)]: x_pair, y_pair = sorted((x, y)) if pair_max[x_pair][y_pair] < max_val: pair_max[x_pair][y_pair] = max_val total = 0 for x in range(1, N + 1): for y in range(x + 1, N + 1): total += pair_max[x][y] count = N * (N - 1) // 2 if count == 0: expectation = 0.0 else: expectation = total / count if expectation > max_expectation or (expectation == max_expectation and idx < best): max_expectation = expectation best = idx print(best) if __name__ == '__main__': main()