CodeEff/ECCO huggingface dataset:
# Original solution
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())
n, = list(map(int,readline().split()))
vw = [(0,0)]+[tuple(map(int,readline().split())) for _ in range(n)]

A = 10
N = min(1<<A,n+1)

memo = [None for _ in range(N)]
L = 10**5+1
memo[0] = [0]*L

for i in range(1,N):
    m = memo[i>>1][:]
    v,w = vw[i]    
    for j in range(L-1,w-1,-1):
        if m[j] < m[j-w]+v:
            m[j] = m[j-w]+v
    memo[i] = m

q, = list(map(int,readline().split()))
for _ in range(q):
    u,l = list(map(int,readline().split()))

    m = u.bit_length() - A
    if m<0: m=0
    dv = [0]*(1<<m)
    dw = [0]*(1<<m)
    for i in range(m):
        v,w = vw[u]
        for j in range(1<<i):
            dv[j+(1<<i)] = dv[j]+v
            dw[j+(1<<i)] = dw[j]+w
        u >>= 1
    
    ans = 0
    for v,w in zip(dv,dw):
        if w <= l:
            ans = max(ans,memo[u][l-w]+v)
    print(ans)

        


# Optimized solution
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = list(map(int,readline().split()))
vw = [(0,0)]+[tuple(map(int,readline().split())) for _ in range(n)]

A = 10
N = min(1<<A,n+1)

memo = [None for _ in range(N)]
L = 10**5+1
memo[0] = [0]*L

for i in range(1,N):
    m = memo[i>>1][:]
    v,w = vw[i]    
    for j in range(L-1,w-1,-1):
        if m[j] < m[j-w]+v:
            m[j] = m[j-w]+v
    memo[i] = m

q, = list(map(int,readline().split()))
for _ in range(q):
    u,l = list(map(int,readline().split()))

    m = u.bit_length() - A
    if m<0: m=0
    dv = [0]*(1<<m)
    dw = [0]*(1<<m)
    for i in range(m):
        v,w = vw[u]
        for j in range(1<<i):
            dv[j+(1<<i)] = dv[j]+v
            dw[j+(1<<i)] = dw[j]+w
        u >>= 1
    
    ans = 0
    for v,w in zip(dv,dw):
        if w <= l:
            val = memo[u][l-w] + v
            if val > ans: ans = val
    print(ans)
# Original solution
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = list(map(int,readline().split()))
vw = [(0,0)]+[tuple(map(int,readline().split())) for _ in range(n)]

A = 10
N = min(1<<A,n+1)

memo = [None for _ in range(N)]
L = 10**5+1
memo[0] = [0]*L

for i in range(1,N):
    m = memo[i>>1][:]
    v,w = vw[i]    
    for j in range(L-1,w-1,-1):
        if m[j] < m[j-w]+v:
            m[j] = m[j-w]+v
    memo[i] = m

q, = list(map(int,readline().split()))
for _ in range(q):
    u,l = list(map(int,readline().split()))

    m = u.bit_length() - A
    if m<0: m=0
    dv = [0]*(1<<m)
    dw = [0]*(1<<m)
    for i in range(m):
        v,w = vw[u]
        for j in range(1<<i):
            dv[j+(1<<i)] = dv[j]+v
            dw[j+(1<<i)] = dw[j]+w
        u >>= 1
    
    ans = 0
    for v,w in zip(dv,dw):
        if w <= l:
            val = memo[u][l-w] + v
            if val > ans: ans = val
    print(ans)

        


# Optimized solution
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int,readline().split())
vw = [(0,0)]+[tuple(map(int,readline().split())) for _ in range(n)]

A = 10
N = min(1<<A,n+1)

memo = [None for _ in range(N)]
L = 10**5+1
memo[0] = [0]*L

for i in range(1,N):
    m = memo[i>>1][:]
    v,w = vw[i]    
    for j in range(L-1,w-1,-1):
        if m[j] < m[j-w]+v:
            m[j] = m[j-w]+v
    memo[i] = m

q, = map(int,readline().split())
ans_ = [0]*q
for _ in range(q):
    u,l = map(int,readline().split())

    m = u.bit_length() - A
    if m<0: m=0
    dv = [0]*(1<<m)
    dw = [0]*(1<<m)
    for i in range(m):
        v,w = vw[u]
        for j in range(1<<i):
            dv[j+(1<<i)] = dv[j]+v
            dw[j+(1<<i)] = dw[j]+w
        u >>= 1
    
    ans = 0
    for v,w in zip(dv,dw):
        if w <= l:
            val = memo[u][l-w] + v
            if val > ans: ans = val
    ans_[_] = ans
    
print(*ans_,sep="\n")
# Original solution
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()
print(*max_list,sep="\n")


# Optimized solution
from collections import Counter
a=open(0)
n=int(a.readline())
l=a.read().split()
c=Counter(l)
d=max(c.values())
max_list=[k for k,v in c.items() if v==d]
max_list.sort()
print(*max_list,sep="\n")
# Original solution
N=int(input())
d={}
for i in range(N):
  tmp = input()
  if tmp in d:
    d[tmp] += 1
  else:
    d[tmp] = 1

a = d.items()
b = d.values()
max_k_list = [kv[0] for kv in a if kv[1] == max(b)]
[print(i) for i in sorted(max_k_list)]


# Optimized solution
N=int(input())
d={}
for i in range(N):
  tmp = input()
  if tmp in d:
    d[tmp] += 1
  else:
    d[tmp] = 1

max_v=max(d.values())
ans=list(filter(lambda x: x[1] == max_v, d.items()))
[print(i[0]) for i in sorted(ans)]
# Original solution
from collections import Counter

N, *S = open(0).read().split()
count = Counter(S)
ans_list = [i for i, j in list(count.items()) if j == max(count.values())]
ans_list.sort()
print(("\n".join(ans_list)))

# Optimized solution
from collections import Counter

N, *S = open(0).read().split()
count = Counter(S)
max_value = max(count.values())
ans_list = [i for i, j in list(count.items()) if j == max_value]
ans_list.sort()
print(("\n".join(ans_list)))
# Original solution
N=int(input())
S=[]
for _ in range(N):
  S.append(input())
  
import collections

c=collections.Counter(S)
vl=list(c.values())
mv=max(vl)

ans=[]
cc=list(c.items())
cc.sort(key=lambda x:x[1], reverse=True)

for k, v in cc:
  if v==mv:
    ans.append(k)
  else:
    break
ans.sort()
[print(a) for a in ans]
  


# Optimized solution
N=int(input())
S=[]
for _ in range(N):
  S.append(input())
  
import collections

c=collections.Counter(S)
vl=list(c.values())
# 最大要素数
mv=max(vl) 

ans=[]
cc=list(c.items()) # 辞書を[key, value]のリストにする
cc.sort(key=lambda x:x[1], reverse=True) # valueで降順ソート
# 辞書リスト内のkey, valueを調べる
for k, v in cc:
  if v==mv: # valueが要素数最大のやつ
    ans.append(k)
  else:
    break
ans.sort()
[print(a) for a in ans]
# Original solution
from collections import Counter
N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res=[]
for letter,count in counted.most_common() :
    if count < counted.most_common()[0][1]:
        break
    else:
        res.append(letter)

[print(i) for i in sorted(res)]


# Optimized solution
from collections import Counter


N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res_max= counted.most_common()[0][1]
ans = []
for k, v in counted.items():
    if v == res_max:
        ans.append(k)

ans.sort()
print(*ans, sep="\n")
# Original solution
from collections import Counter
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    s_c = Counter(s)
    # keys = [k for k, v in s_c.items() if v == max(s_c.values())]
    # keys_s = sorted(keys)
    keys =[k for k, v in s_c.items() if v == s_c.most_common()[0][1]]
    keys_s = sorted(keys)
    print(*keys_s, sep='\n')

if __name__ == '__main__':
    main()


# Optimized solution
from collections import Counter
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    s_c = Counter(s)
    s_c_max = s_c.most_common()[0][1]
    keys =[k for k, v in s_c.items() if v == s_c_max]
    keys_s = sorted(keys)
    print(*keys_s, sep='\n')

if __name__ == '__main__':
    main()
# Original solution
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    cnt = sorted(Counter(s).items(), key=lambda x: -x[1])
    m = cnt[0][1]
    ans = [s for s, c in cnt if c == m]
    print(*sorted(ans), sep='\n')
         

if __name__ ==  '__main__':
    main()


# Optimized solution
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    c = Counter(s)
    m = max(c.values())
    ans = [s for s, v in c.items() if v == m]
    print(*sorted(ans), sep='\n')
         
if __name__ ==  '__main__':
    main()
# Original solution
from collections import defaultdict

N = int(input())
s_counter = defaultdict(int)
for _ in range(N):
    S = input()
    s_counter[S] += 1
S_list = sorted(s_counter.items(), key=lambda x: x[1], reverse=True)
answer = []
for i in range(len(S_list)):
    if S_list[0][1] != S_list[i][1]:
        break
    answer.append(S_list[i][0])
answer.sort()
[print(a) for a in answer]


# Optimized solution
from collections import Counter

N = int(input())
counter = Counter([input() for _ in range(N)])
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

print(*names, sep='\n')
# Original solution
import sys
from collections import Counter

input = sys.stdin.readline

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

c = Counter(S).most_common()

words = []
max = c[0][1]
for i in range(len(c)):
    if max == c[i][1]:
        words.append(c[i][0])

words.sort()
print(*words, sep='\n')


# Optimized solution
import sys
from collections import Counter

input = sys.stdin.readline

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

c = Counter(S)
max = max(c.values())

words = [k for k, v in c.items() if max == v]
words.sort()

print(*words, sep='\n')
# Original solution
import sys
input=sys.stdin.readline
n=int(eval(input()))
p=[]
for i in range(n):
	s=input().rstrip()
	p.append(s)
p.sort()
ans=0
cnt=1
for i in range(n-1):
	if p[i]==p[i+1]:
		cnt+=1
	else:
		ans=max(ans,cnt)
		cnt=1
ans=max(ans,cnt)
q=[]
for i in range(n-ans+1):
	if p[i]==p[i+ans-1]:
		q.append(p[i])
q.sort()
for i in range(len(q)):
	print((q[i]))


# Optimized solution
table={}
import sys
input=sys.stdin.readline
n=int(eval(input()))
ss=[]
for i in range(n):
	s=input().rstrip()
	if s in table:
		table[s]+=1
	else:
		table[s]=1
		ss.append(s)
ans=[]
saidai=max(table.values())
for i in range(len(ss)):
	if table[ss[i]]==saidai:
		ans.append(ss[i])
ans.sort()
for x in ans:
	print(x)
# Original solution
from collections import Counter
import sys
input = sys.stdin.readline

def solve():
    N = int(eval(input()))
    Sss = [input().rstrip() for _ in range(N)]

    cnt = Counter(Sss)
    #print('cnt:', cnt)

    maxNum = max(cnt.values())
    #print('maxNum:', maxNum)

    anss = []
    for key, value in list(cnt.items()):
        if value == maxNum:
            anss.append(key)
    #print('anss:', anss)

    anss.sort()

    print(('\n'.join(anss)))


solve()


# Optimized solution
from collections import Counter
import sys
input = sys.stdin.readline

N = int(eval(input()))
Sss = [input().rstrip() for _ in range(N)]

cnt = Counter(Sss)

num = max(cnt.values())

anss = []
for key in sorted(cnt.keys()):
    if cnt[key] == num:
        anss.append(key)

print(('\n'.join(anss)))
# Original solution
import collections
n = int(input())
dd = collections.defaultdict(int)
for _ in range(n):
    dd[input()] += 1
ans = []
for key in dd.keys():
    ans.append((dd[key], key))
ans.sort(reverse=True)
ans2 = [ans[0][1]]
for i in range(1, len(ans)):
    if ans[i - 1][0] != ans[i][0]:
        break
    ans2.append(ans[i][1])
ans2.sort()
print(*ans2, sep='\n')


# Optimized solution
import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.Counter(s).most_common()
ans = []
for i in range(1, len(s) + 1):
    ans.append(s[i - 1][0])
    if i == len(s):
        break
    if s[i - 1][1] != s[i][1]:
        break
ans.sort()
print(*ans, sep='\n')
# Original solution
import sys
import collections

n = eval(input())
arr = [_.replace('\n', '') for _ in sys.stdin]
dic = collections.Counter(arr)

s = [k for k,v in list(dic.items()) if v == max(dic.values())]
for i in sorted(s):
  print(i)


# Optimized solution
import sys
import collections

n = eval(input())
arr = [_.replace('\n', '') for _ in sys.stdin]
dic = collections.Counter(arr)
cnt = list(dic.values()).count(max(dic.values()))
s = [k for k,v in dic.most_common(cnt)]

for i in sorted(s):
  print(i)
# Original solution
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    values, counts = zip(*cnt.most_common())
    d = sorted(values[:counts.count(counts[0])])
    print(*d, sep='\n')

if __name__ == '__main__':
    main()


# Optimized solution
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    cnt_max = max(cnt.values())
    d = [k for k, v in cnt.items() if v == cnt_max]
    d = sorted(d)
    print(*d, sep='\n')

if __name__ == '__main__':
    main()
# Original solution
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c.most_common()[i][1] != max_num:
        break
    else:
        ans_list.append(c.most_common()[i][0])

print(*sorted(ans_list), sep='\n')


# Optimized solution
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c_max[i][1] != max_num:
        break
    else:
        ans_list.append(c_max[i][0])

print(*sorted(ans_list), sep='\n')
# Original solution
from collections import Counter

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

dic = Counter(S)

tmp = max(dic.values())
ans = [key for key, value in dic.items() if value == tmp]

# もうちょいかっこいい書き方があるはず。リストを1行1str出力 and 最後に改行しないように
for key in sorted(ans):
    print(key, end="")
    print("")


# Optimized solution
from collections import Counter

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

dic = Counter(S)

tmp = max(dic.values()) # ここ重要！
ans = [key for key, value in dic.items() if value == tmp]

# もうちょいかっこいい書き方があるはず。リストを1行1str出力 and 最後に改行しないように
"""
for key in sorted(ans):
    print(key, end="")
    print("")
"""


ans.sort()
print(*ans, sep="\n")


# print(*ans, sep="\n") かっこいい書き方
# Original solution
import collections

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

dicdata = collections.Counter(data)

newdata = [k for k, v in dicdata.items() if v == max(dicdata.values())]

newdata.sort()

[print(i) for i in newdata]


# Optimized solution
import collections

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

dicdata = collections.Counter(data)

m = max(dicdata.values())

newdata = [k for k, v in dicdata.items() if v == m]

newdata.sort()

[print(i) for i in newdata]
# Original solution
import sys
from collections import Counter

input = sys.stdin.readline

N = int(eval(input()))
l = []
for _ in range(N):
    l.append(input().strip())

c = Counter(l)

for k, v in sorted(list(c.items()), key=lambda x: x[0]):
    if v == max(c.values()):
        print(k)


# Optimized solution
import sys
from collections import Counter

input = sys.stdin.readline

N = int(eval(input()))
l = []
for _ in range(N):
    l.append(input().strip())

c = Counter(l)
m = max(c.values())
c2 = [k for k, v in list(c.items()) if v == m]

for x in sorted(c2):
    print(x)
# Original solution
N=int(input())
S=list(input() for _ in range(N))

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[]
for k, v in cnt.items():
	if v!=max_cnt:
		continue
	ans.append(k)
print(*sorted(ans), sep="\n")


# Optimized solution
N=int(input())
S=list(input() for _ in range(N))

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[name for name, cnt in cnt.items() if cnt==max_cnt]
print(*sorted(ans), sep="\n")
# Original solution
N,*S=open(0).read().split()
import collections

C=collections.Counter(S)
keys = [k for k, v in list(C.items()) if v == max(C.values())]
keys.sort()

for i in keys:
    print(i)

# Optimized solution
N,*S=open(0).read().split()
import collections

C=collections.Counter(S)
M=max(C.values())
keys = [k for k, v in list(C.items()) if v == M]
keys.sort()

for i in keys:
    print(i)
# Original solution
from operator import itemgetter 

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

dic = {}
for i in S:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
        
dic_sorted = sorted(list(dic.items()), key=itemgetter(1, 0))[::-1]

res = []
n = dic_sorted[0][1]
i = 0
l = len(dic_sorted)
while i < l and dic_sorted[i][1] == n:
    #print(dic_sorted[i][0])
    res = [dic_sorted[i][0].decode()] + res
    i += 1
    
print(('\n'.join(res)))

# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

S = sorted(S)
ls = [[] for i in range(N + 1)]
max_num = 0
left = 0
right = 0
while right < N:
    while right < N and S[left] == S[right]:
        right += 1
    if (right  - left) >= max_num:
        ls[right - left].append(S[left].decode())
        max_num = right - left
    left = right
    
print(('\n'.join(ls[max_num])))
# Original solution
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
rst = [ key for key, val in dic.items() if val == max(dic.values()) ]
[ print(i) for i in sorted(rst) ]


# Optimized solution
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]
# Original solution
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]


# Optimized solution
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if not s in dic:
        dic[s] = 1
    else:
        dic[s] += 1
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]
# Original solution
from sys import stdin

n = int(stdin.readline().rstrip())
s = []
d = [0] * 200000 
max = 1

for i in range(n):
    t = stdin.readline().rstrip()
    d[i] = 1
    for ss in s:
        if t == ss:
            d[i] = d[i] + 1
            if max < d[i]:
                max = d[i]
    s.append(t)

result = []        
for cnt in range(len(d)):
    if d[cnt] == max:
        result.append(s[cnt])

result.sort()
for r in result:
    print(r)


# Optimized solution
from sys import stdin
import math

n = int(stdin.readline().rstrip())

d = {}
max = 0
for i in range(n):
    s = stdin.readline().rstrip()
    if s in list(d.keys()):
        d[s] += 1
    else:
        d[s] = 1
    if max < d[s]:
        max = d[s]

result = []
for key, value in list(d.items()):
    if value == max:
        result.append(key)

result.sort()

for i in range(len(result)):
    print((result[i]))
# Original solution
n,*s=list(map(str,open(0).read().split()))
mydict={}
for i in set(s):
    mydict[i]=1
for i in range(int(n)):
    mydict[s[i]]+=1
    """
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
    """
for i in sorted([kv[0] for kv in list(mydict.items()) if kv[1]==max(mydict.values())]):
    print(i)

# Optimized solution
n,*s=list(map(str,open(0).read().split()))
mydict={}
for i in set(s):
    mydict[i]=1
for i in s:
    mydict[i]+=1
    """
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
    """
v_max=max(mydict.values())
for i in sorted([kv[0] for kv in list(mydict.items()) if kv[1]==v_max]):
    print(i)
# Original solution
import collections
n = int(input())
s=[input() for i in range(n)]
ans = list()

c = collections.Counter(s)
k = c.most_common()[0][1]

if n == 1:
    print(s[0])
elif n >= 2 and len(c.keys()) == 1:
    print(c.most_common()[0][0])
elif n >= 2 and len(c.keys()) == len(s):
    ans = s
else:
    for i in range(n):
        if k == c.most_common()[i][1]:
            ans.append(c.most_common()[i][0])
        else:
            break

ans = sorted(ans)
[print(i) for i in ans]


# Optimized solution
import collections
n = int(input())
s=[input() for i in range(n)]
ans = list()

c = collections.Counter(s)

m = max(c.values())
for k,v in c.items():
    if v ==m:
        ans.append(k)
ans.sort()
print(*ans,sep="\n")
# Original solution
n = int(input())
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
    else:
        s = input()
        if s in S:
            S[s] += 1
        else:
            S[s] = 1
max_k_list = [kv[0] for kv in S.items() if kv[1] == max(S.values())]
ans = sorted(max_k_list)
for a in ans:
    print(a, sep="\n")


# Optimized solution
n = int(input())
ans = []
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
        ans.append(s)
        mx = 1
    else:
        s = input()
        if s in S:
            S[s] += 1
            if S[s] > mx:
                ans = [s]
                mx = S[s]
            elif S[s] == mx:
                ans.append(s)
        else:
            S[s] = 1
            if S[s] == mx:
                ans.append(s)
ans = sorted(ans)
for a in ans:
    print(a, sep="\n")
# Original solution
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
c = Counter(S)
l = c.most_common()
max = l[0][1]
answer = []
for k, v in l:
    if v == max:
        answer.append(k)

answer.sort()
for a in answer:
    print(a)


# Optimized solution
# coding: utf-8
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
counter = Counter(S)
mo = counter.most_common()
ma = mo[0][1]
answer = []
for k, v in mo:
    if v == ma:
        answer.append(k)

answer.sort()
print(*answer, sep='\n')
# Original solution
from collections import Counter

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

C = Counter(S).most_common()

ma = C[0][1]
ans = sorted(k for k, v in C if v == ma)

for a in ans:
    print(a)

# Optimized solution
from collections import Counter

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

C = Counter(S)

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

for a in ans:
    print(a)