N = int(input())
names = []
for _ in range(N):
name = input()
names.append(name)
name_count = {}
for name in names:
if name in name_count:
name_count[name] += 1
else:
name_count[name] = 1
max_count = 0
most_frequent_name = ""
for name, count in name_count.items():
if count > max_count:
max_count = count
most_frequent_name = name
print(most_frequent_name, max_count)