단순 구현 문제이며 어떻게 원하는 케이크가 가장 많은 사람을 일단 따로 정리하는 배열과, 각 사람에 맞는 개수를 체크해주는 방문 배열을 따로 설정해줘서 해당 번호에 맞는 received를 채워준다.
L = int(input())
n = int(input())
cake = [0] * (L+1)
received = [0] * (n+1)
want = []
for i in range(1, n+1):
a, b = map(int, input().split())
cnt = 0
want.append(b-a)
for j in range(a, b+1):
if cake[j] == 0:
cake[j] = i
cnt += 1
received[i] = cnt
print(want.index(max(want)) + 1)
print(received.index(max(received)))