n, m = map(int, input().split())
total_score = []
progress = []
regress = []
good = 0 # 紀錄進步最大值
bad = 0 # 紀錄退步最大值
best_progress_student = -1 # 學生座號
worst_regress_student = -1
for i in range(n):
total_score.append([int(x) for x in input().split()])
for i in range(n):
current_progress = 0 # 累加當前學生進步幅度
current_regress = 0 # 累加當前學生退步幅度
for j in range(m-1):
diff = total_score[i][j+1] - total_score[i][j] #計算這次與上次考試分數的差值
if diff > 0:
current_progress += diff
else:
current_regress += -diff
if current_progress > good:
good = current_progress
best_progress_student = i + 1
if current_regress > bad:
bad = current_regress
worst_regress_student = i + 1
print(best_progress_student)
print(worst_regress_student)