Untitled

mail@pastecode.io avatar
unknown
python
a year ago
700 B
0
Indexable
Never
def get_input():
    inp = list(map(lambda x: int(x), input().split()))
    return inp[0], inp[1]


def find_indices(list_to_check, item_to_find):
    return [idx for idx, value in enumerate(list_to_check) if value == item_to_find]


person_count, n = get_input()

knows = [[] for x in range(person_count)]
known_by = [[] for x in range(person_count)]

for i in range(n):
    a, b = get_input()
    knows[a - 1].append(b)
    known_by[b - 1].append(a)

result_arr = list(map(lambda x: len(known_by[x]) - len(knows[x]), range(person_count)))
max_value = max(result_arr)

result_arr = find_indices(result_arr, max_value)
print(result_arr[-1] + 1, len(known_by[result_arr[-1]]))