peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
dic = {}

for i in range(N):
    S = input()
    if S not in dic:
        dic[S] = 1
    else:
        dic[S] += 1

sortDic = sorted(dic.items(), key=lambda x:x[1],reverse=True)

list = []
list.append(sortDic[0][0])
j = 0

if len(sortDic) != 1:
    while j < len(sortDic)-1 and sortDic[j][1] == sortDic[j+1][1]:
        list.append(sortDic[j+1][0])
        j += 1

list = sorted(list)

for i in range(len(list)):
    print(list[i])
n=int(input())
ans={"b":0}
ma=0
pr=[]
for i in range(n):
    name=input()
    if name in ans.keys():
        ans[name]=ans[name]+1
    else:
        ans[name]=1
for j,k in ans.items():
    if k>ma:
        ma=k 
        pr=[j]
    elif k==ma:
        pr.append(j)
pr.sort()
for l in pr:
    print(l)
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
n=int(input())
dic={}
for i in range(n):
  a=input()
  if a not in dic.keys():dic[a]=1
  else:dic[a]+=1
max_value=max(dic.values())
dic_max=[k for k, v in dic.items() if v==max_value]
dic_s=sorted(dic_max)
[print(i) for i in dic_s]
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k,v in c.items() if m==v])
[print(k) for k in ans]
N = int(input())

_dict = {}
max_cnt = 0
for n in range(N):
  _ = input()
  if _ not in _dict:
    _dict[_] = 1
  else:
    _dict[_] += 1
    
  if _dict[_] > max_cnt:
    max_cnt = _dict[_]


ans = [k for k, v in _dict.items() if v == max_cnt]
ans.sort()
for _ in ans:
  print(_)
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''
n = int(input())
a = [input() for i in range(n)]

ans = []

import collections
counter = collections.Counter(a)

max_h = max(counter.values())


for i in counter.items():
    #print(i)
    if i[1] == max_h:
        ans.append(i[0])
    else:
        pass

ans.sort()

[print(i) for i in ans]
from collections import Counter

n=int(input())
s=[]
for i in range(n):
  a=input()
  s.append(a)
c=Counter(s)

mx=max(c.values())
ans=[]
for i in c:
  if c[i]==mx:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = list(c.keys())
li.sort()
max = li[-1]
lia = []
for i in ca:
    if c[i] == max:
        lia.append(i)
lia.sort()
n = len(lia)
for i in range(n):
    print(lia[i])
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
S = []
S2 = []

for _ in range(N):
    S.append(input().strip())

count = Counter(S)
most = max(count.values())
for key, value in count.items():
    if value == most:
        S2.append([key, value])

S2.sort(key=lambda x:x[0])
for value in S2:
    print(value[0])
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

print("\n".join(ans))
n=int(input())
s=[input() for i in range(n)]
from collections import Counter
c=Counter(s)
c=list(c.most_common())

m=0
ans=[]
for k,v in c:
  if v>=m:
    ans.append(k)
    m=v
ans.sort()
print(*ans,sep='\n')
N=int(input())
a=[]
b=0
for i in range(N):
	a.append(input())
d={}
sor={}
for i in range(N):
    if a[i] in d.keys():
        d[a[i]]+=1
    else:
        d.setdefault(a[i],1)
        b+=1
sod = sorted(d.keys())
#max=sod["a[0]"]
maxval=0
for i in range(N):
    if maxval<=d[a[i]]:
        maxval=d[a[i]]
for i in range(b):
    if maxval==d[sod[i]]:
        print(sod[i])
from collections import defaultdict

n = int(input())
d = defaultdict(int)
m = 0
for i in range(n):
    s = input()
    d[s] += 1
    m = max(m,d[s])

ans = []
for k,v in d.items():
    if v == m:
        ans.append(k)

ans.sort()
for a in ans:
    print(a)
n = int(input())
S = dict()
for i in range(n):
    word = input()
    if word not in S:
        S[word] = 1
    else:
        S[word] += 1
S = sorted(S.items(), key=lambda x:x[1], reverse=True)

max_v = S[0][1]
ans = []
for k,v in S:
    if v == max_v:
        ans.append(k)
    else:
        break
ans = sorted(ans)
for i in ans:
    print(i)
n = int(input())
dd = {}
for i in range(n):
	s = input()
	if s in dd.keys():
		dd[s] += 1
	else:
		dd[s] = 1
ma = max(dd.values())
lst = []
for k, v in dd.items():
	if v == ma:
		lst.append(k)
for l in sorted(lst):
	print(l)
from collections import defaultdict

n = int(input())
ss = [input().strip() for _ in range(n)]

counts = defaultdict(int)

for s in ss:
    counts[s] += 1

items = list(counts.items())
items = sorted(items, key=lambda c: c[1], reverse=True)

max_value = items[0][1]
max_items = [item for item in items if item[1] == max_value]

keys = [item[0] for item in max_items]
keys = sorted(keys)

for key in keys:
    print(key)
import numpy as np

n = int(input())
s_list = [input() for i in range(n)]

new_dict = {}
for s in s_list:
    if s not in new_dict.keys():
        new_dict[s] = 1
    else:
        new_dict[s] += 1
    
values = []
keys = []    
for key in new_dict.keys():
    values.append(new_dict[key])
    keys.append(key)
    
values = np.array(values)
keys = np.array(keys)

max_index = values == np.max(values)
keys = keys[max_index].tolist()
keys = sorted(keys)

for key in keys:
    print(key)
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
li = [stdin.readline().rstrip() for _ in range(n)]
li.sort()
lin = []
for key, value in groupby(li):
    lin.append((key,len(list(value))))
lin.sort(key=lambda x:(x[1]*(-1),x[0]))
point = lin[0][1]
for i,j in lin:
    if j == point:
        print(i)
    else:
        break
n = int(input())
L = list(input() for _ in range(n))
D = dict.fromkeys(set(L),0)

for l in L:
  D[l] += 1

m = max(D.values())
SD = sorted(D.items(), key=lambda x:x[0])

for k, v in SD:
  if v == m:
    print(k)
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    C = Counter(A)
    most_c = C.most_common()
    max_num = most_c[0][1]
    ANS = []
    for c in most_c:
        if c[1] < max_num:
            break
        ANS.append(c[0])
    for ans in sorted(ANS):
        print(ans)


if __name__ == '__main__':
    main()
n = int(input())
ds = {}

for i in range(n):
    s = input()
    if s in ds:
        ds[s] += 1
    else:
        ds[s] = 0

d_sorted = sorted(ds.items(), key=lambda x: x[0])
f_sorted = sorted(d_sorted, key=lambda x: x[1], reverse=True)

i = f_sorted[0][1]

for s in f_sorted:
    if s[1] == i:
        print(s[0])
    else:
        break
from collections import Counter
a = []
for i in range(int(input())):
    a.append(input())
a = Counter(a)
m = a.most_common()[0][1]
for i, j in sorted(a.most_common()):
    if j ==m: print(i)
n = int(input())
s = [input() for _ in range(n)]

import collections
c0 = collections.Counter(s)
c1 = c0.most_common()
max = c1[0][1]
l = []
for x, i in c0.items():
    if i == max:
        l.append(x)
ans = sorted(l)
for i in ans:
    print(i)
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    dic = defaultdict(lambda: 0)
    count = 0
    for _ in range(n):
        s = input()
        dic[s] += 1
        count = max(count, dic[s])

    candidates = []
    for key in dic.keys():
        if dic[key] == count:
            candidates.append(key)

    candidates.sort()
    for c in candidates:
        print(c)

if __name__ == '__main__':
    main()
N = int(input())
dic = dict()
lis = list()
for i in range(N):
    tmp = input()
    lis.append(tmp)
    dic[tmp] =0
maxi = 0
for i in lis:
    dic[i] +=1
    if maxi < dic[i]:
        maxi = dic[i]
result = list()
for name in dic:
    if dic[name] == maxi:
        result.append(name)

for i in sorted(result):
    print(i)
from collections import defaultdict

d = defaultdict(lambda : 0)

n = int(input())
for _ in range(n):
    item = input()
    d[item] += 1

items = sorted(d.items(), key=lambda x: (x[1], x[0]), reverse=True)
c = items[0][1]
l = []
for k, v in items:
    if v < c:
        break
    l.append(k)
if len(l) == 1:
    print(l[0])
else:
    print('\n'.join(l[::-1]))
n=int(input())
dic = {}
max = 1
for i in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
        if max < dic[s]:
            max = dic[s]
l = []
for i in dic.keys():
    if dic[i] == max:
        l += [i]
l.sort()
for i in l:
    print(i)
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
smax = max(Counter(s).values())
kmax = [k for k, v in Counter(s).items() if v == smax]
print("\n".join(sorted(kmax)))
n = int(input())
dict = {}
max = 1
for i in range(n):
  str = input()
  if str in dict:
    dict[str] = dict[str] + 1
    if dict[str] > max:
      max += 1
  else:
    dict[str] = 1
keys = [k for k, v in dict.items() if v == max]
keys.sort()
for i in range(len(keys)):
  print(keys[i])
import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]
import collections 

n=int(input())
a=[]
for i in range(n):
    s=input()
    a.append(s)

b=collections.Counter(a) 
mx=max(b.values())
ans=[]

for word,counts in b.items():
    if counts==mx:
        ans.append(word)
        
ans=sorted(ans)
for i in ans:
    print(i)
N=int(input())
from collections import Counter
c=Counter([input() for i in range(N)]).most_common()
r=[]
V=c[0][1]
for k,v in c:
    if v!=V:
        break
    r.append(k)
print(*sorted(r),sep="\n")
n = int(input())
s = {}
for i in range(n):
  t = input()
  if t in s:
    s[t] += 1
  else:
    s[t] = 1
s = sorted(s.items(), key=lambda x:x[1], reverse=True)
vmax = s[0][1]
ans = []
for si in s:
  if si[1] == vmax:
    ans.append(si[0])
  else:
    break
ans.sort()
for a in ans:
  print(a)
n = int(input())
s = {}
for _ in range(n):
  line = input()
  if line in s:
    s[line] += 1
  else:
    s[line] = 1
s = sorted(s.items(), reverse=True, key=lambda x : x[1])
tn = s[0][1]
ans = []
for l in s:
  if l[1] == tn:
    ans.append(l[0])
  else:
    break
for l in sorted(ans):
  print(l)
def main():
    N = int(input())
    S = {}
    for _ in range(N):
        s = input()
        if s not in S:
            S[s] = 1
        else:
            S[s] += 1

    v_max = max(S.values())
    keys = [k for k, v in S.items() if v == v_max]
    keys.sort()

    for k in keys:
        print(k)


if __name__ == "__main__":
    main()
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    s_list = [input().rstrip() for _ in range(n)]

    from collections import Counter
    c = Counter(s_list)

    max_count = c.most_common()[0][1]

    words = [word for word, count in c.most_common() if count == max_count]
    words.sort()
    print("\n".join(words))




if __name__ == "__main__":
    resolve()
from collections import defaultdict
def main():
    n = int(input())
    s =defaultdict(lambda:0)
    for i in range(n):
        s[input()] += 1
    max_s = max(s.values())
    for key, value in sorted(s.items()):
        if value == max_s:
            print(key)

if __name__ == "__main__":
    main()
n=int(input())
a=[]
d={}
b=0
m=0
for i in range(n):
    s=input()
    try:
        a[d[s]][1]+=1
    except:
        d[s]=b
        a.append([s,1])
        b+=1
    m=max(m,a[d[s]][1])
a.sort()
for i in range(len(a)):
    if a[i][1]==m:
        print(a[i][0])
import collections
N = int(input())
List = [str(input()) for i in range(N)]
c = collections.Counter(List)
#print(c.most_common()[0])
#print(c.most_common()[1])
#print(c.most_common())

most=[]
most_num=c.most_common()[0][1]
for i in c.most_common():
    if i[1]==most_num:
        most.append(i[0])
most.sort()
for i in most:
    print(i)
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
num = Counter(s)
mx = max(num.values())
T = []
for n in sorted(num):
    if num[n] == mx:
        print(n)
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
  if word in dictionary:
    dictionary[word]+=1
  else:
    dictionary[word]=1
maximum=max(dictionary.values())
for key, value in sorted(dictionary.items()):
  if value==maximum:
    print(key)
from collections import defaultdict
from collections import OrderedDict

N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k] += 1
    else:
        ans.update({k: 1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
#C
N = int(input())
memo = {}
max_word = 1
for i in range(N):
    Si = input()
    try:
        memo[Si] += 1
        max_word = max(max_word, memo[Si])
    except:
        memo[Si] = 1
        
keys = [k for k, v in memo.items() if v == max_word]
keys.sort()
for item in keys:
  print(item)
N = int(input())

d = {}
for _ in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1

max_val = max(d.values())
keys = [k for k, v in d.items() if v == max_val]
for k in sorted(keys):
    print(k)
n=int(input())
l=[input() for _ in range(n)]
from collections import Counter as co
d=co(l)
k=max(d.values())
x=[]
for i,j in d.items():
  if j==k:
    x.append(i)
x.sort()
for i in x:
  print(i)
#python3
from collections import defaultdict
from operator import itemgetter

def main():
    n = int(input())
    a = [input() for _ in range(n)]
    s = defaultdict(int)
    for i in a:
        s[i]+=1  
    
    t = []
    for i, j in s.items():
        t.append((i, j))

    t.sort(reverse=True,key=itemgetter(1))
    MAX = t[0][1]
    ans = []
    for i, j in t:
        if j == MAX:
            ans.append(i)
    ans.sort()
    for i in ans:
        print(i)
main()
n = int(input())
s = []
while True:
    try:
        s.append(input())
    except EOFError:
        break

word_counter = {}
for word in s:
    if word in word_counter:
        word_counter[word] += 1
    else:
        word_counter[word] = 0

results = sorted(word_counter.items(), key=lambda x: x[1], reverse=True)
max_v = results[0][1]

pick_ups = [result[0] for result in results if result[1] == max_v]
sorted_pick_ups = sorted(pick_ups)
print(*sorted_pick_ups, sep='\n')
from collections import Counter
def solve():
  N = int(input())
  S = [input() for _ in range(N)]
  c = Counter(S)
  M = max(c.values())
  ans = []
  for k,v in c.items():
    if v==M:
      ans.append(k)
  ans.sort()
  return ans
print(*solve(),sep='\n')
import pprint
N = int(input())
S = {}
for i in range(N):
    tmp = input()
    if tmp in S.keys():
        S[tmp] = S[tmp] + 1
    else:
        S[tmp] = 1
    #pprint.pprint(S)

num = 0
v = []
for key,value in S.items():
    if value > num:
        num = value
        v = [key]
    elif value == num:
        v.append(key)

v.sort()

for i in v:
    print(i)
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    t = {}
    m = 0
    for s in S:
        t[s] = t.get(s, 0) + 1
        m = max(m, t[s])
    r = []
    for k, v in t.items():
        if v == m:
            r.append(k)
    r.sort()
    print('\n'.join(r))





main()
n = int(input())
num = dict()
for i in range(n):
    s = input()
    if s in num:
        num[s] += 1
    else:
        num[s] = 1
num_s = sorted(num.items(), key=lambda x:x[1],reverse=True)
max_num = max(num.values())
ans = []
for i in range(len(num_s)):
    if num_s[i][1] == max_num:
        ans.append(num_s[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])
n = int(input())
s = [input() for i in range(n)]

d = {}
cnt = 0
for i in range(n):
	if s[i] in d: d[s[i]] += 1
	else: d[s[i]] = 1
	cnt = max(cnt, d[s[i]])

l = []
for i in range(n):
	if d[s[i]] == cnt:
		l.append(s[i])

l = list(set(l))
l.sort()
for i in range(len(l)):
	print(l[i])
N = int(input())

S_dict = dict()

for i in range(N):
    S = str(input())
    if S not in S_dict:
        S_dict[S] = 1
    else:
        S_dict[S] += 1

score_S_list = sorted(S_dict.items(), key=lambda x:x[1] ,reverse=True)

max_polled = score_S_list[0][1]

max_polled_S = list()

for S in score_S_list:
    if S[1] == max_polled:
        max_polled_S.append(S[0])
    else:
        break
        
max_polled_S.sort()

for S in max_polled_S:
    print(S)
n = int(input())

dic = {}

for i in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1
    
max_num = max(dic[word] for word in dic)
l = []
for word in dic:
  if dic[word]==max_num:
    l.append(word)
    
l = sorted(l)
for i in range(len(l)):
  print(l[i])
from collections import Counter

N = int(input())
S = [input() for i in range(N)]

c = Counter(S)
l = list(c.most_common())
A = []
for i,j in l:
    if j == l[0][1]:
        A.append(i)

A.sort()

for i in A:
    print(i)
n = int(input())
s = {}
count = 0
while n > count:
    st = input()
    if st not in s:
        s[st] = 1
        count += 1
    else:
        s[st] += 1
        count += 1

sorteditems = sorted(s.items(), key = lambda x : x[1], reverse= True)
max = 0
ans = []
for a, b in sorteditems:
    if max == 0:
        ans.append(a)
        max = b
    elif max == b:
        ans.append(a)
for i in sorted(ans):
    print(i)
# coding: utf-8
# Your code here!

import collections
a = int(input())
li1 = []
 
for i in range(a):
    li1.append(str(input()))
 
c = collections.Counter(li1)
 
sorted_items = sorted(
  c.most_common(),
  key = lambda x:(x[1],x[0]), reverse=True)
 
key, value = zip(*sorted_items)
li2 = []
li2.append(key[0])
for i in range(1,len(key)):
    if(value[0] == value[i]):
        li2.append(key[i])
    else:
        break;

list.sort(li2)

for i in range(len(li2)):
    print(li2[i])
from collections import Counter
N = int(input())
S = []
for _ in range(N):
  S.append(input())
C = Counter(S).most_common()
_,M = C[0]
L = []
for a,b in C:
  if b == M:
    L.append(a)
print(*sorted(L) ,sep = "\n")
N = int(input())
S = [input() for i in range(N)]
d = dict()
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
l = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = l[0][1]
res = []
for x in l:
    if x[1] == maxv:
        res.append(x[0])
for x in sorted(res):
    print(x)
from collections import Counter

n = int(input())
s = [input() for i in range(n)]

d = Counter(s)
m = max(d.values())
ans = [i for i in d if d[i] == m]
ans = sorted(ans)

for i in ans:
    print(i)
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 0
        
m = max(d.values())
ans = []
for t in d:
    if d[t] == m:
        ans.append(t)
ans.sort()
for u in ans:
    print(u)
import collections
import itertools
N=int(input())
di = dict()
l = list()
for i in range(N):
    l.append( input())

c = collections.Counter(l)
ct = c.most_common()
m = ct[0][1]
li = list()
for t in ct:
    if m == t[1]:
        li.append(t[0]) 
    else:
        break
lis = sorted(li)
for s in lis:
    print(s)
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
max_ = max(c.values())
c = sorted([k for k, v in c.items() if v == max_])
for a in c:
    print(a)
import collections

n = int(input())
s = list(input() for i in range(n))
s = sorted(s)
c = collections.Counter(s)
p = max(c.values())
s = sorted(list(set(s)))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])
from collections import defaultdict

n = int(input())
dd = defaultdict(int)

for _ in range(n):
    dd[input()]+=1

maxnum = max(dd.values())

arr=[]

for k in dd:
    if dd[k]==maxnum:
        arr.append(k)

for a in sorted(arr):
    print(a)
from collections import OrderedDict
from collections import defaultdict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k] += 1
    else:
        ans.update({k: 1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
N = int(input())
dic = {}

for _ in range(N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] = dic[inp] + 1

num = max(dic.values())
ans = []
for i in dic:
  if dic[i] == num:
    ans.append(i)
    
ans.sort()
for i in ans:
  print(i)
# -*- coding: utf-8 -*-
import collections


def main():
    n = int(input())
    s = [input() for i in range(n)]

    most_counters = collections.Counter(s).most_common()
    most_count = most_counters[0][1]

    for t in sorted(map(lambda x: x[0], filter(lambda x: x[1] == most_count, most_counters))):
        print(t)


if __name__ == '__main__':
    main()
from collections import Counter
n = int(input())
d = [input() for _ in range(n)]
c = Counter(d).most_common()
now = c[0][1]

data = []
for x in c:
    if x[1] < now:
        break
    data.append(x[0])
data.sort()
for x in data:print(x)
from collections import Counter
n=int(input())
string_list = [input() for i in range(n)]
str_counter = Counter(string_list)
most_count = 0
l = []
for v in str_counter.values():
  if v > most_count:
    most_count = v

for k,v in str_counter.items():
  if v == most_count:
    l.append(k)
l.sort()
for i in l:
  print(i)
N = int(input())
S = [input() for _ in range(N)]

S_ = {}
for a in S:
  if a not in S_:
    S_[a] = 1
  else:
    S_[a] += 1

S_ = sorted(S_.items(), key=lambda x:-x[1])

#print(S_)
max_ = 0
a = []
for i in range(len(S_)):
  #print(S_[i][1], )
  if S_[i][1] >= max_:
    max_ = S_[i][1]
    #print(a)
    a.append(S_[i][0])
  else:
    break
a =sorted(a)
print(*a)
import collections

N = int(input())
S = [input() for _ in range(N)]

cnt = collections.Counter(S)
max_cnt = max(cnt.values())

ans_list = []

for key, value in cnt.items():
    if value == max_cnt:
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')
import collections
N = int(input())
S = {}
for i in range(N):
    value = input()
    if value not in S:
        S[value] = 1
    else:
        S[value] += 1
S_largest = max(S.values())
S_sorted = sorted(S.items(), key=lambda x:x[1], reverse=True)
ans = []
for i in range(len(S_sorted)):
    if S_sorted[i][1] == S_largest:
        ans.append(S_sorted[i][0])
    else:
        break
ans_sorted = sorted(ans)
for a in ans_sorted:
    print(a)
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 0
max_val = max(dict.values())
max_list = [k for k, v in dict.items() if v == max_val]
max_list.sort()
for i in max_list:
    print(i)
# coding: utf-8

def main():
    n = int(input())
    lines = []
    for i in range(0, n):
        lines.append(input())

    dct = {}
    for l in lines:
        if l in dct:
            dct[l] += 1;
        else:
            dct[l] = 1;

    cmax = max(dct.values())

    print('\n'.join(sorted([k for k,v in dct.items() if v == cmax])))

if __name__ == '__main__':
    main()
import collections

N = int(input())
S = list(input() for i in range(N))
S.sort()

common = collections.Counter(S).most_common()
N_common = common[0][1]

candidates = [cand for cand in common if cand[1] == N_common]

for i in sorted(candidates):
    print(i[0])
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
cnt=max(c.values())
tmp = [k for k, v in c.items() if cnt==v]
print(*sorted(tmp), sep='\n')
from collections import Counter

n=int(input())
l=[input() for i in range(n)]
c=Counter(l)
d=max(c.values())
max_list=[k for k,v in c.items() if v==d]
max_list.sort()
for j in max_list:
  print(j)