AtCoder Beginner Contest 155 - Poll

We have N voting papers. The i-th vote (1 \leq i \leq N) has the string S_i written on it.
Print all strings that are written on the most number of votes, in lexicographical order.

-----Constraints-----
 - 1 \leq N \leq 2 \times 10^5
 - S_i (1 \leq i \leq N) are strings consisting of lowercase English letters.
 - The length of S_i (1 \leq i \leq N) is between 1 and 10 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
N
S_1
:
S_N

-----Output-----
Print all strings in question in lexicographical order.

-----Sample Input-----
7
beat
vet
beet
bed
vet
bet
beet

-----Sample Output-----
beet
vet

beet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.

Source: atcoder | Difficulty: EASY


Solutions:
N = int(input())
D = {}
M = 1
for _ in range(N):
	S = input()
	if S in D:
		D[S] += 1
		M = max(M, D[S])
	else:
		D[S] = 1
K = [a for a in D if D[a] == M]
K.sort()
for a in K:
	print(a)


from collections import Counter
n = int(input())
a = []
for i in range(n):
	a.append(input())
b = Counter(a)
m = max(b.values())
for (k, v) in sorted(b.items()):
	if v == m:
		print(k)


n = int(input())
d = dict()
for _ in range(n):
	a = input()
	if a in d:
		d[a] += 1
	else:
		d[a] = 1
m = max(d.values())
keys = [k for (k, v) in d.items() if v == m]
print('\n'.join(sorted(keys)))


import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
x = c.most_common()[0][1]
s = list(set(s))
s.sort()
for item in s:
	if c[item] == x:
		print(item)


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
m = c.most_common()[0][1]
k = list(c.keys())
v = list(c.values())
l = []
for i in range(len(c)):
	if v[i] == m:
		l.append(k[i])
l.sort()
print(*l, sep='\n')


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
cnts = Counter(S)
max_l = max(cnts.values())
ans = [s for (s, c) in cnts.items() if c == max_l]
ans.sort()
print(*ans, sep='\n')


from collections import Counter
k = [input() for _ in range(int(input()))]
l = Counter(k)
m = l[max(l, key=lambda x: l[x])]
ans = sorted(filter(lambda x: l[x] == m, l))
print(*ans, sep='\n')


N = int(input())
dc = {}
for i in range(N):
	s = input()
	if s in dc:
		dc[s] += 1
	else:
		dc[s] = 1
m = max(dc.values())
w = [kv[0] for kv in dc.items() if kv[1] == m]
w.sort()
for p in w:
	print(p)


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
S_Counter = Counter(S)
Max = max(set(S_Counter.values()))
print('\n'.join(sorted((s for (s, v) in S_Counter.items() if v == Max))))


n = int(input())
cnt = {}
for i in range(n):
	s = input()
	if s in cnt:
		cnt[s] += 1
	else:
		cnt[s] = 1
res = []
maks = max(list(cnt.items()), key=lambda x: x[1])
for item in list(cnt.items()):
	if item[1] == maks[1]:
		res.append(item[0])
res.sort()
for s in res:
	print(s)


from collections import Counter
n = int(input())
l = [input() for i in range(n)]
c = Counter(l)
ml = c.most_common()
mc = ml[0][1]
ml.sort()
for i in ml:
	if i[1] == mc:
		print(i[0])


N = int(input())
dic = {}
for i in range(N):
	s = input()
	if s in dic:
		dic[s] += 1
	else:
		dic[s] = 1
sai = max(dic.values())
for j in sorted((k for k in dic if dic[k] == sai)):
	print(j)


n = int(input())
dic = {}
for x in range(n):
	a = input()
	dic.setdefault(a, 0)
	dic[a] += 1
dic2 = sorted(list(dic.items()), key=lambda x: x[1], reverse=True)
max_word = [k for (k, v) in dic2 if v == dic2[0][1]]
max_word.sort()
for x in max_word:
	print(x)


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s.sort()
d = Counter(s)
a = 0
for v in d.values():
	if v > a:
		a = v
for k in d.keys():
	if d[k] == a:
		print(k)


n = int(input())
p = [str(input()) for _ in range(n)]
import collections
c = collections.Counter(p)
m = max(c.values())
keys = [k for (k, v) in c.items() if v == m]
keys.sort()
for i in keys:
	print(i)


from collections import *
(n, *s) = open(0)
cnt = Counter(s).most_common()
ans = sorted((a * (b == cnt[0][1]) for (a, b) in cnt))
for i in ans:
	print(i, end='')


import collections
n = int(input())
l = []
for i in range(n):
	l.append(input())
c = collections.Counter(l)
m = max(c.values())
chars = [key for (key, value) in c.items() if value == m]
chars.sort()
for s in chars:
	print(s)


n = int(input())
s = list((input() for _ in range(n)))
d = {}
for i in range(n):
	if s[i] in d:
		d[s[i]] += 1
	else:
		d[s[i]] = 1
m = max(d.values())
for s in sorted((k for k in d if d[k] == m)):
	print(s)


n = int(input())
from collections import *
c = Counter()
for _ in range(n):
	c[input()] += 1
m = max(c.values())
print(*sorted((k for (k, v) in c.items() if v == m)))


import collections
n = int(input())
c = collections.Counter([input() for i in range(n)])
ma = max(c.values())
print(*sorted([i for (i, j) in c.items() if j == ma]), sep='\n')


N = int(input())
S = [input() for _ in range(N)]
dic = {}
for i in range(N):
	if S[i] not in list(dic.keys()):
		dic[S[i]] = 1
	else:
		dic[S[i]] += 1
maxI = max(dic.values())
ans = []
for keys in list(dic.keys()):
	if dic[keys] == maxI:
		ans.append(keys)
ans.sort()
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] = 1
m = max(d.values())
ans = []
for (i, k) in d.items():
	if m == k:
		ans.append(i)
for i in sorted(ans):
	print(i)


from collections import Counter
(_, *s) = open(0)
c = Counter(s).most_common()
print(*sorted((a * (b == c[0][1]) for (a, b) in c)))


n = int(input())
s = [input() for _ in range(n)]
count = {}
for word in s:
	if word not in count:
		count[word] = 1
	else:
		count[word] += 1
max_count = max(list(count.values()))
ans = []
for item in list(count.items()):
	(key, value) = item
	if value == max_count:
		ans.append(key)
ans = sorted(ans)
for w in ans:
	print(w)


from collections import Counter
N = int(input())
S = Counter((input() for _ in range(N)))
max_count = max(S.values())
for s in sorted((s for s in S if S[s] == max_count)):
	print(s)


from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
max_s = max(s.values())
print(*sorted([k for (k, v) in s.items() if v == max_s]), sep='\n')


N = int(input())
S = []
M = 1
count = 1
for _ in range(N):
	S.append(input())
S.sort()
ans = [S[0]]
for i in range(N - 1):
	if S[i] == S[i + 1]:
		count += 1
	else:
		if M < count:
			M = count
			ans = [S[i]]
		elif M == count:
			ans.append(S[i])
		count = 1
if M < count:
	M = count
	ans = [S[N - 1]]
elif M == count:
	ans.append(S[N - 1])
ans = list(set(ans))
ans.sort()
for j in range(len(ans)):
	print(ans[j])


n = int(input())
s = [input() for i in range(n)]
nl = {i: 0 for i in set(s)}
c = 0
for i in s:
	nl[i] += 1
	if nl[i] > c:
		c = nl[i]
ans = [i for i in set(s) if nl[i] == c]
ans.sort()
[print(i) for i in ans]


from collections import Counter
N = int(input())
S = [input() for i in range(N)]
s = Counter(S)
m = max(s.values())
s = sorted(s.items(), key=lambda s: s[0])
for a in s:
	if a[1] == m:
		print(a[0])


from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
	dic[input()] += 1
m = max(dic.values())
for k in sorted(dic.keys()):
	if dic[k] == m:
		print(k)


from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
mc = c.most_common()
ans = [i[0] for i in mc if i[1] == mc[0][1]]
ans.sort()
for i in ans:
	print(i)


N = int(input())
d = {}
for i in range(N):
	s = input()
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
l = sorted(d.items())
M = max(d.values())
for i in l:
	if d[i[0]] == M:
		print(i[0])


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


n = int(input())
s = {}
for _ in range(n):
	_s = input()
	if _s in s:
		s[_s] = s[_s] + 1
	else:
		s[_s] = 1
s = sorted(s.items(), key=lambda x: (x[1], x[0]))
max = s[-1][1]
for i in s:
	if i[1] == max:
		print(i[0])


c = {}
for _ in range(int(input())):
	s = input()
	c[s] = c.get(s, 0) + 1
m = max(c.values())
print(*sorted((k for k in c if c[k] == m)))


from collections import Counter
c = Counter((input() for _ in range(int(input()))))
m = c.most_common(1)[0][1]
for s in sorted((s for (s, k) in c.items() if k == m)):
	print(s)


n = int(input())
d = {}
m = 0
for i in range(n):
	s = input()
	if s not in d:
		d[s] = 1
	else:
		d[s] += 1
	m = max(m, d[s])
t = set()
for i in d:
	if d[i] == m:
		t.add(i)
x = [i for i in t]
x.sort()
for i in x:
	print(i)


n = int(input())
d = {}
max_value = 1
for i in range(n):
	s = input()
	if s in d:
		d[s] += 1
		max_value = max(max_value, d[s])
	else:
		d[s] = 1
l = []
for k in d:
	if d[k] == max_value:
		l.append(k)
for x in sorted(l):
	print(x)


n = int(input())
d = {}
for i in range(n):
	s = input()
	d[s] = d.get(s, 0) + 1
m = max(d.values())
maxKeys = [x[0] for x in d.items() if x[1] == m]
so = sorted(maxKeys)
for e in so:
	print(e)


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)


from collections import Counter
N = int(input())
Ss = [input() for _ in range(N)]
ct = Counter(Ss)
M = ct.most_common(1)[0][1]
for s in sorted(ct.keys()):
	if ct[s] == M:
		print(s)


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
ans = c.most_common()
ans = [i[0] for i in ans if i[1] == ans[0][1]]
for i in sorted(ans):
	print(i)


import collections
N = int(input())
l = [input() for i in range(N)]
L = collections.Counter(l)
a = L.most_common()
M = a[0][1]
A = [j[0] for j in a if j[1] == M]
[print(k) for k in sorted(A)]


n = int(input())
d = {}
for i in range(n):
	k = input()
	d[k] = d.get(k, 0) + 1
val = list(d.values())
key = list(d.keys())
m = max(val)
key.sort()
for i in key:
	if d[i] == m:
		print(i)


d = dict()
for i in range(int(input())):
	s = input()
	if s not in d:
		d[s] = 1
	else:
		d[s] += 1
max_v = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_v]))


import collections
N = int(input())
S = collections.Counter((input() for i in range(N)))
maximum = max(S.values())
sort = sorted((key for (key, value) in S.items() if value == maximum))
for s in sort:
	print(s)


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)


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')


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]


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
d = Counter(s)
m = max(d.values())
keys = [k for (k, v) in d.items() if v == m]
print('\n'.join(sorted(keys)))


from collections import Counter
N = int(input())
S = [''] * N
for i in range(N):
	S[i] = input()
S = Counter(S).most_common()
c = S[0][1]
print(*sorted([a for (a, s) in S if s == c]), sep='\n')


from collections import Counter
C = Counter()
for _ in range(int(input())):
	C[input()] += 1
m = max(C.values())
ans = []
for (key, val) in C.items():
	if val == m:
		ans.append(key)
ans.sort()
print(*ans)


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

def LI():
	return list(map(int, input().split()))

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	N = I()
	D = defaultdict(int)
	for i in range(N):
		D[input().rstrip()] += 1
	D = D.items()
	D = sorted(D, key=lambda x: x[0])
	D = sorted(D, key=lambda x: x[1], reverse=True)
	num = D[0][1]
	for (key, n) in D:
		if n != num:
			return
		print(key)

def __starting_point():
	main()
__starting_point()


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)]


import collections
N = int(input())
S = []
for i in range(N):
	S.append(input())
c = collections.Counter(S).most_common()
ans = []
if len(c) == 1:
	ans = c
else:
	for k in range(N):
		if c[0][1] == c[k][1]:
			ans.append(c[k])
		else:
			break
for x in sorted(ans):
	print(x[0])


import collections
n = int(input())
s = [input() for i in range(n)]
counter = collections.Counter(s)
m = max(counter.values())
for j in sorted(counter):
	if counter[j] == m:
		print(j)


from itertools import groupby
a = groupby(sorted((input() for _ in range(int(input())))))
a = [(len(tuple(g)), s) for (s, g) in a]
m = max(a)[0]
for (k, s) in a:
	if k == m:
		print(s)


from collections import *
n = int(input())
s = Counter((input() for _ in range(n)))
l = sorted(((-i, k) for (k, i) in s.items()))
m = l[0][0]
for (i, k) in l:
	if i != m:
		break
	print(k)


N = int(input())
dict = {}
for i in range(N):
	s = input()
	if s in dict:
		dict[s] += 1
	else:
		dict[s] = 1
max_count = max(dict.values())
for (k, v) in sorted(dict.items()):
	if v == max_count:
		print(k)


n = int(input())
d = {}
for i in range(n):
	s = input()
	d[s] = d.get(s, 0) + 1
m = max((d[i] for i in d))
for s in sorted(d):
	if d[s] == m:
		print(s)


from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
	dic[input()] += 1
max_s = max(dic.values())
for (k, v) in sorted(dic.items()):
	if v == max_s:
		print(k)


import collections
n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)
mx = max(c.values())
A = [e for (e, j) in c.items() if j == mx]
A.sort()
for p in A:
	print(p)


from collections import Counter
n = int(input())
s = [input() for i in range(n)]
num = Counter(s)
mx = max(num.values())
for i in sorted(num):
	if num[i] == mx:
		print(i)


n = int(input())
l = [str(input()) for i in range(n)]
l = sorted(l)
cnt = 1
cnt_max = 1
moji = []
for i in range(1, n):
	if l[i] == l[i - 1]:
		cnt += 1
		if i == n - 1:
			if cnt_max < cnt:
				cnt_max = cnt
				moji = [l[i - 1]]
			elif cnt_max == cnt:
				moji.append(l[i - 1])
	else:
		if cnt_max < cnt:
			cnt_max = cnt
			moji = [l[i - 1]]
		elif cnt_max == cnt:
			moji.append(l[i - 1])
			if cnt_max == 1 and i == n - 1:
				moji.append(l[i])
		cnt = 1
for i in range(len(moji)):
	print(moji[i])


from collections import Counter
N = int(input())
Ss = [input() for i in [0] * N]
C = Counter(Ss)
m = max(C.values())
ans = sorted([k for (k, v) in C.items() if v == m])
for a in ans:
	print(a)


N = int(input())
dct = {}
for i in range(N):
	s = input()
	if not s in dct:
		dct[s] = 1
	else:
		dct[s] += 1
m = max(dct.values())
for s in sorted((k for k in dct if dct[k] == m)):
	print(s)


N = int(input())
S = {}
for n in range(N):
	s = input()
	if s not in S.keys():
		S[s] = 1
	else:
		S[s] += 1
m = max(S.values())
S2 = sorted(S)
for s in S2:
	if S[s] == m:
		print(s)


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S).most_common()
m = c[0][1]
print('\n'.join(sorted((s[0] for s in c if s[1] == m))))


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
max_v = max(cnt.values())
ans = [s for (s, c) in cnt.items() if c == max_v]
ans.sort()
print('\n'.join(ans))


n = int(input())
d = {}
for _ in range(n):
	s = input()
	d[s] = d.get(s, 0) + 1
n = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == n]
for i in sorted(max_k_list):
	print(i)


N = int(input())
d = {}
for _ in range(N):
	p = input()
	if p in d:
		d[p] += 1
	else:
		d[p] = 1
ma = max(d.values())
d2 = sorted(d.items())
d.clear()
d.update(d2)
for (k, v) in list(d.items()):
	if v == ma:
		print(k)


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
c_max = max(c.values())
[print(x) for x in sorted([s for s in set(S) if c[s] == c_max])]


from collections import Counter
N = int(input())
c = Counter([input() for _ in range(N)])
mv = max(c.values())
[print(w) for w in sorted(c.keys()) if c[w] == mv]


import collections
S = collections.Counter([input() for _ in range(int(input()))]).most_common()
m = S[0][1]
L = []
for s in S:
	if s[1] == m:
		L.append(s[0])
for l in sorted(L):
	print(l)


n = int(input())
s_l = [input() for _ in range(n)]
d = {}
for s in s_l:
	try:
		d[s] += 1
	except:
		d[s] = 1
max_c = max([v for (_, v) in d.items()])
ans = [i for (i, v) in d.items() if v == max_c]
for i in sorted(ans):
	print(i)


n = int(input())
S = [input() for i in range(n)]
from collections import Counter
c = Counter(S)
mc = c.most_common()
m = mc[0][1]
ls = [c[0] for c in mc if c[1] == m]
ls.sort()
for i in ls:
	print(i)


N = int(input())
dic = {}
for i in range(N):
	si = input()
	if si in dic.keys():
		dic[si] += 1
	else:
		dic[si] = 1
n = max(dic.values())
for (k, v) in sorted(dic.items()):
	if v == n:
		print(k)


import collections
N = int(input())
S = [input() for _ in range(N)]
count = collections.Counter(S)
maxV = max(count.values())
c = [k for (k, v) in count.items() if v == maxV]
print('\n'.join(sorted(c)))


n = int(input())
d = {}
for _ in range(n):
	s = input()
	d[s] = d.get(s, 0) + 1
m = max(d.values())
ans = []
for s in d:
	if d[s] == m:
		ans.append(s)
ans.sort()
for a in ans:
	print(a)


N = int(input())
S = [input() for _ in range(N)]
import collections
C = collections.Counter(S)
maxC = max(C.values())
keys = [k for (k, v) in C.items() if v == maxC]
[print(j) for j in sorted(keys)]


from collections import Counter
N = int(input())
A = [input() for x in range(N)]
cnt = Counter(A)
mx = max(cnt.values())
s = [s for (s, v) in cnt.items() if v == mx]
s.sort()
print('\n'.join(s))


n = int(input())
s = [input() for _ in [0] * n]
d = {}
for i in s:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
num = max(d.values())
ans = [i for i in d if d[i] == num]
print('\n'.join(sorted(ans)))


n = int(input())
d = {}
t = 0
for i in range(n):
	s = input()
	d[s] = d.get(s, 0) + 1
	t = max(t, d[s])
for key in sorted(d):
	if d[key] == t:
		print(key)


N = int(input())
l = [input() for _ in range(N)]
l = sorted(l)
import collections
c = collections.Counter(l)
d = c.most_common()
for i in range(len(d)):
	if d[i][1] == d[0][1]:
		print(d[i][0])


import collections
n = int(int(input()))
a = [input() for i in range(n)]
m = collections.Counter(a).most_common()
print('\n'.join(sorted([a for (a, b) in m if b == m[0][1]])))


from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
C = Counter(S)
C_most = C.most_common()
ans = []
for (key, val) in C_most:
	if val == C_most[0][1]:
		ans.append(key)
	else:
		break
print(*sorted(ans), sep='\n')


import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s).most_common()
ans = [k for (k, v) in c if c[0][1] == v]
ans.sort()
for i in ans:
	print(i)


n = int(input())
d = {}
m = 0
for i in range(n):
	s = input()
	d[s] = d.get(s, 0) + 1
	if m <= d[s]:
		m = d[s]
c = []
for i in d:
	if d[i] == m:
		c.append(i)
c.sort()
for x in c:
	print(x)


from collections import Counter
c = Counter((input() for _ in range(int(input()))))
m = max(c.values())
for s in sorted((s for (s, k) in c.items() if k == m)):
	print(s)


N = int(input())
S = [input() for _ in range(N)]
cnts = {key: 0 for key in S}
for key in S:
	cnts[key] += 1
max_cnt = max(cnts.values())
ans = [k for (k, v) in cnts.items() if v == max_cnt]
ans.sort()
print(*ans, sep='\n')


from collections import defaultdict

def main():
	N = int(input())
	dic = defaultdict(int)
	max_p = 0
	for i in range(N):
		dic[input()] += 1
	d = dict(dic)
	l = []
	for (key, value) in list(d.items()):
		l.append([key, value])
		if max_p < value:
			max_p = value
	l.sort(key=lambda x: (-x[1], x[0]), reverse=False)
	for (i, j) in l:
		if j == max_p:
			print(i)
		else:
			break

def __starting_point():
	main()
__starting_point()


import collections
n = int(input())
s = []
for _ in range(n):
	s.append(str(input()))
ans = collections.Counter(s)
a = max(ans.values())
ans = [i for (i, k) in ans.items() if a == k]
print(*sorted(ans), sep='\n')


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
C = Counter(S)
M = max(C.values())
print(*sorted((k for (k, v) in C.items() if v == M)), sep='\n')


n = int(input())
s = {}
for i in range(n):
	a = input()
	if a in s:
		s[a] += 1
	else:
		s[a] = 1
max = max(s.values())
s = sorted(s.items())
for i in s:
	if i[1] == max:
		print(i[0])


N = int(input())
d = {}
for i in range(N):
	tmp = input()
	d[tmp] = d.get(tmp, 0) + 1
m = max((d[i] for i in d))
max_list = [i for i in d if d[i] == m]
print('\n'.join(sorted(max_list)))


from collections import *
(n, *s) = map(str, open(0).read().split())
s = Counter(s).most_common()
print(*sorted(((a + '\n') * (i == s[0][1]) for (a, i) in s)))


N = int(input())
S = [input() for _ in range(N)]
d = {s: 0 for s in set(S)}
for i in range(N):
	d[S[i]] += 1
count = 0
for key in d:
	count = max(count, d[key])
l = []
for key in d:
	if count == d[key]:
		l.append(key)
l.sort()
for s in l:
	print(s)


from collections import *
N = int(input())
count = Counter([input() for _ in range(N)])
m = max(count.values())
ans = [a for (a, b) in count.items() if b == m]
ans.sort()
for S in ans:
	print(S)


from collections import defaultdict
charnums = defaultdict(int)
N = int(input())
for _ in range(N):
	charnums[input()] += 1
ans = []
m = max(charnums.values())
for (key, value) in charnums.items():
	if value == m:
		ans.append(key)
for an in sorted(ans):
	print(an)


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())
count_dict = {}
for i in range(n):
	i = input()
	if i in count_dict.keys():
		count_dict[i] += 1
	else:
		count_dict[i] = 0
max_value = max(count_dict.values())
for (key, value) in sorted(count_dict.items()):
	if value == max_value:
		print(key)


N = int(input())
S = [input() for i in range(N)]
import collections
s = collections.Counter(S)
M = max(s.values())
s = [e for e in s if s[e] == M]
t = sorted(s)
for e in t:
	print(e)


n = int(input())
d = {}
for i in range(n):
	s = input()
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
mx = max(d.values())
ans = ['']
for (k, v) in d.items():
	if v == mx:
		ans.append(k)
ans.sort()
print(*ans, sep='\n')


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))
for a in ans:
	print(a)


import collections
n = int(input())
l1 = list()
for i in range(n):
	l1.append(input())
c = collections.Counter(l1)
m = max(c.values())
C = sorted(c.items())
for i in C:
	if i[1] == m:
		print(i[0])


d = {}
for _ in range(int(input())):
	i = input()
	d[i] = d.get(i, 0) + 1
m = max(list(d.values()))
l = [i for i in d.keys() if d[i] == m]
l.sort()
for i in l:
	print(i)


n = int(input())
s = {}
for _ in range(n):
	a = str(input())
	s[a] = s.get(a, 0)
	s[a] += 1
t = max(s.values())
ans = []
for k in s:
	if s[k] == t:
		ans.append(k)
ans.sort()
print(*ans)


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')


from collections import Counter
k = int(input())
p = Counter((input() for f in range(k)))
j = sorted(p.most_common(), key=lambda a: 1 - a[1])
j = [m[0] for m in j if m[1] == j[0][1]]
print('\n'.join(sorted(j)))


n = int(input())
s = [input() for _ in range(n)]
from collections import Counter
c = Counter(s)
d = []
x = c.most_common()[0][1]
for k in c.keys():
	if c[k] == x:
		d.append(k)
d.sort()
print(*d, sep='\n')


from collections import Counter
n = int(input())
lst = [input() for i in range(n)]
c = Counter(lst)
c2 = c.most_common()
m = c2[0][1]
ans = [i[0] for i in c2 if i[1] == m]
print('\n'.join(sorted(ans)))


def main():
	n = int(input())
	d = dict()
	for _ in range(n):
		s = input()
		if s not in list(d.keys()):
			d[s] = 1
		else:
			d[s] += 1
	mostFrequent = max(d.values())
	ans = []
	for key in list(d.keys()):
		if d[key] == mostFrequent:
			ans.append(key)
	ans.sort()
	for i in ans:
		print(i)

def __starting_point():
	main()
__starting_point()


import collections
n = int(input())
l = [str(input()) for i in range(n)]
c = collections.Counter(l).most_common()[::1]
res = sorted([i[0] for i in c if i[1] == c[0][1]])
[print(i) for i in res]


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)


N = int(input())
(dic, lis) = ({}, [])
for i in range(N):
	s = input()
	if s in dic:
		dic[s] += 1
	else:
		dic[s] = 1
M = max(dic.values())
for s in dic.keys():
	if dic[s] == M:
		lis.append(s)
ans = sorted(lis)
for s in ans:
	print(s)


n = int(input())
l = [input() for i in range(n)]
from collections import Counter as co
k = co(l).most_common()
d = k[0][1]
print(*sorted([a for (a, s) in k if s == d]), sep='\n')


n = int(input())
d = {}
for _ in range(n):
	s = str(input())
	d[s] = 1 if s not in d else d[s] + 1
M = max(d.values())
L = [k for (k, v) in d.items() if v == M]
L.sort()
for x in L:
	print(x)


import numpy as np
(N,) = map(int, input().split())
dic = {}
for i in range(N):
	x = input()
	if x in dic:
		dic[x] += 1
	else:
		dic[x] = 1
c = max(dic.values())
re = []
for i in dic:
	if dic[i] == c:
		re += [i]
re.sort()
for i in re:
	print(i)


q = int(input())
dic = {}
for i in range(q):
	s = input()
	if not s in dic:
		dic[s] = 1
	else:
		dic[s] += 1
max_val = max(dic.values())
a = sorted([i for (i, k) in list(dic.items()) if k == max_val])
for i in a:
	print(i)


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 v == m))
print('\n'.join(ans))


n = int(input())
s = [input() for _ in range(n)]
ans = []
d = {}
for i in s:
	try:
		d[i] += 1
	except KeyError:
		d[i] = 1
mx = 0
for value in list(d.values()):
	if value > mx:
		mx = value
for (key, value) in list(d.items()):
	if value == mx:
		ans.append(key)
for v in sorted(ans):
	print(v)


n = int(input())
s = {}
for i in range(n):
	a = input()
	if a in s:
		s[a] += 1
	elif a not in s:
		s.update({a: 1})
b = max(s.values())
for i in sorted((k for k in s if s[k] == b)):
	print(i)


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
l = max(cnt.values())
ans = [s for (s, j) in cnt.items() if j == l]
ans.sort()
print('\n'.join(ans))


import collections

def i_input():
	return int(input())

def i_map():
	return list(map(int, input().split()))

def i_list():
	return list(map(int, input().split()))

def i_row(N):
	return [int(input()) for _ in range(N)]

def i_row_list(N):
	return [list(map(int, input().split())) for _ in range(N)]
n = i_input()
ss = [input() for _ in range(n)]
ss.sort()
c = collections.Counter()
for word in ss:
	c[word] += 1
prtcnt = max(c.values())
for (word, cnt) in list(c.items()):
	if cnt == prtcnt:
		print(word)


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)


(N, *S) = open(0).read().split()
import collections
C = collections.Counter(S)
M = max(C.values())
keys = [k for (k, v) in C.items() if v == M]
keys.sort()
for i in keys:
	print(i)


N = int(input())
D = {}
for _ in range(N):
	S = input()
	if S not in D:
		D[S] = 0
	D[S] += 1
M = max(D.values())
for S in sorted(list(D)):
	if D[S] == M:
		print(S)


N = int(input())
d = dict()
m = 0
for _ in range(N):
	s = input()
	d[s] = d.get(s, 0) + 1
	m = max(m, d[s])
ans = sorted((k for (k, v) in d.items() if v == m))
print(*ans, sep='\n')


from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(n):
	d[input()] += 1
m = max(d.values())
for (i, j) in sorted(d.items()):
	if j == m:
		print(i)


import collections
n = int(input())
s = [input() for _ in range(n)]
counter = collections.Counter(s)
m = max(counter.values())
for v in sorted(counter):
	if counter[v] == m:
		print(v)


import collections
N = int(input())
S = []
ans = []
for i in range(N):
	S.append(input())
d = collections.Counter(S)
ome = max(d.values())
for (k, v) in list(d.items()):
	if v == ome:
		ans.append(k)
ans.sort()
for x in ans:
	print(x)


from collections import Counter
n = int(input())
a = [input() for _ in range(n)]
c = Counter(a)
max_cnt = max(c.values())
names = [name for (name, v) in c.items() if v == max_cnt]
names.sort()
print(*names, sep='\n')


N = int(input())
ss = dict()
for i in range(N):
	s = input()
	ss[s] = ss.get(s, 0) + 1
sss = [(-b, a) for (a, b) in list(ss.items())]
sss.sort()
maxa = sss[0][0]
for (a, b) in sss:
	if maxa != a:
		break
	print(b)


import math
import statistics
import collections
a = int(input())
g = [input() for _ in range(a)]
g.sort()
ma = 0
count = 1
for i in range(a - 1):
	if g[i] == g[i + 1]:
		count += 1
	else:
		ma = max(ma, count)
		count = 1
ma = max(ma, count)
count = 1
ans = []
for i in range(a - 1):
	if g[i] == g[i + 1]:
		count += 1
	else:
		if count == ma:
			ans.append(g[i])
		count = 1
if count == ma:
	ans.append(g[-1])
for i in ans:
	print(i)


import collections as cl
n = int(input())
s = [input() for _ in range(n)]
dic = cl.Counter(s)
m = max(dic.values())
ret = [k for (k, v) in dic.items() if v == m]
print('\n'.join(sorted(ret)))


import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
m = max(c.values())
ans = []
for (k, v) in c.items():
	if v == m:
		ans.append(k)
ans.sort()
for a in ans:
	print(a)


N = int(input())
d = {}
for _ in range(N):
	s = input()
	d[s] = d.get(s, 0) + 1
c = max(d.values())
for (s, v) in sorted(d.items()):
	if v == c:
		print(s)


N = int(input())
dic = {}
for _ in range(N):
	S = input()
	if S in dic:
		dic[S] += 1
	else:
		dic[S] = 1
lst = []
M = max(dic.values())
for k in dic.keys():
	if dic[k] == M:
		lst.append(k)
lst.sort()
for i in range(len(lst)):
	print(lst[i])


from collections import defaultdict
d = defaultdict(int)
n = int(input())
for i in range(n):
	s = input()
	d[s] += 1
M = max(d.values())
d1 = sorted(d.items())
for (i, k) in d1:
	if k == M:
		print(i)


import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
mv = c.most_common()[0][1]
l = [i for (i, v) in c.items() if v == mv]
l.sort()
for j in l:
	print(j)


import collections
N = int(input())
S = list((input() for _ in range(N)))
S = collections.Counter(S)
maxnum = max(S.values())
[print(res) for res in sorted([s for s in S if S[s] == maxnum])]


import sys
input = sys.stdin.readline
import collections

def main():
	words = []
	word_dict = []
	n = int(input())
	words = [input().rstrip() for _ in range(n)]
	answers = []
	word_dict = collections.Counter(words)
	max_count = max(word_dict.values())
	[answers.append(values) for (values, counts) in word_dict.most_common() if counts == max_count]
	for answer in sorted(answers):
		print(answer)

def __starting_point():
	main()
__starting_point()


n = int(input())
S = {}
for i in range(n):
	s = input()
	if s not in S.keys():
		S[s] = 1
	else:
		S[s] += 1
m = max(S.values())
ans = []
for (key, value) in S.items():
	if value == m:
		ans.append(key)
ans.sort()
print(*ans, sep='\n')


from collections import Counter
n = int(input())
word = Counter([input() for i in range(n)]).most_common()
print('\n'.join(sorted([num[0] for num in word if int(num[1]) == word[0][1]])))


(n, *s) = map(str, open(0).read().split())
from collections import *
c = Counter(s).most_common()
maxm = c[0][1]
ans = []
for (i, j) in c:
	if maxm == j:
		ans += (i,)
for b in sorted(ans):
	print(b)


import collections
n = int(input())
li = []
for i in range(n):
	li.append(input())
cnt = collections.Counter(li)
S = cnt.most_common()
C = len(cnt)
li_1 = [S[0][0]]
for i in range(C - 1):
	if S[i][1] == S[i + 1][1]:
		li_1.append(S[i + 1][0])
	else:
		break
li_1.sort()
for i in li_1:
	print(i)


N = int(input())
d = {}
for _ in range(N):
	S = input()
	if S in d:
		d[S] += 1
	else:
		d[S] = 1
m = max(d.values())
for s in sorted((k for k in d if d[k] == m)):
	print(s)


n = int(input())
l = []
import collections
for _ in range(n):
	l.append(str(input()))
c = collections.Counter(l)
m = max(c.values())
x = []
for i in sorted(c):
	if c[i] == m:
		print(i)


N = int(input())
from collections import Counter
Sc = Counter([input() for _ in range(N)])
max_count = max(Sc.values())
ans = sorted([k for (k, v) in Sc.items() if v == max_count])
print(*ans, sep='\n')


N = int(input())
d = dict()
for _ in range(N):
	S = input()
	if S not in d:
		d[S] = 0
	d[S] += 1
M = max(d.values())
ans = []
for S in list(d.keys()):
	if d[S] == M:
		ans.append(S)
ans.sort()
for S in ans:
	print(S)


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
countS = Counter(S)
maxS = max(countS.values())
ans = []
for (key, value) in list(countS.items()):
	if value == maxS:
		ans.append(key)
for a in sorted(ans):
	print(a)


from collections import Counter
n = int(input())
s = Counter([input() for _ in range(n)])
mx = max(s.values())
for k in sorted((x for (x, y) in s.items() if y == mx)):
	print(k)


from collections import Counter
N = int(input())
S = Counter((input() for _ in range(N)))
max_app = max(S.values())
print('\n'.join(sorted((k for (k, v) in S.items() if v == max_app))))


n = int(input())
a = {}
for i in range(n):
	s = input()
	if s not in a:
		a.update({s: 0})
	else:
		temp = a[s] + 1
		a.update({s: temp})
max_val = max(list(a.values()))
b = []
for key in a:
	if a[key] == max_val:
		b.append(key)
b.sort()
print(*b, sep='\n')


import collections
s = collections.Counter([input() for s in range(int(input()))])
m = max(s.values())
a = []
for d in s.items():
	if d[1] == m:
		a.append(d[0])
for s in sorted(a):
	print(s)


N = int(input())
ans = {}
for i in range(N):
	a = input()
	ans[a] = ans.get(a, 0) + 1
t = max(ans.values())
ans2 = [k for (k, v) in ans.items() if v == t]
ans2.sort()
[print(i) for i in ans2]


n = int(input())
D = {}
for i in range(n):
	a = input()
	if a in D:
		D[a] += 1
	else:
		D[a] = 1
m = max(D.values())
ans = []
for key in D:
	if D[key] == m:
		ans.append(key)
ans.sort()
for i in ans:
	print(i)


n = int(input())
data = {}
for i in range(n):
	s = str(input())
	if s in data.keys():
		data[s] += 1
	else:
		data[s] = 1
m = max(list(data.values()))
ans = []
for (j, k) in data.items():
	if k == m:
		ans.append(j)
for l in sorted(ans):
	print(l)


n = int(input())
s = [input() for i in range(n)]
s.sort()
dic = [0] * n
for i in range(n - 1):
	if s[i] == s[i + 1]:
		dic[i + 1] = dic[i + 1] + dic[i] + 1
max = max(dic)
for i in range(n):
	if dic[i] == max:
		print(s[i])


import collections as coll
N = int(input())
A = [input() for _ in range(N)]
C = coll.Counter(A).most_common()
C = sorted([k for (k, v) in C if v == C[0][1]])
print(*C, sep='\n')


n = int(input())
S = dict()
for i in range(n):
	s = input()
	if s in S:
		S[s] += 1
	else:
		S[s] = 1
ans = []
cnt = 0
for (k, v) in S.items():
	if v >= cnt:
		if v > cnt:
			ans = []
		ans.append(k)
		cnt = v
print(*sorted(ans), sep='\n')


n = int(input())
a = {}
for i in range(n):
	s = input()
	a[s] = a.get(s, 0) + 1
max_a = max(a.values())
b = sorted([i for i in a.keys() if a[i] == max_a])
[print(i) for i in b]


N = int(input())
S = [input() for i in range(N)]
S.sort()
dic = {}
for i in S:
	dic[i] = 0
for i in S:
	dic[i] += 1
M = max(dic.values())
for i in dic:
	if dic[i] == M:
		print(i)


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)


from collections import Counter
n = int(input())
s = Counter([str(input()) for _ in range(n)])
m = max(s.values())
for x in sorted((x for x in s if s[x] == m)):
	print(x)


import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
b = max(c.values())
l = [key for key in c.keys() if c[key] == b]
l.sort()
for i in l:
	print(i)


import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
sorted_c = c.most_common()
max = sorted_c[0][1]
dict_c = []
for i in range(len(sorted_c)):
	if sorted_c[i][1] == max:
		dict_c.append(sorted_c[i][0])
	else:
		break
dict_c.sort()
for i in range(len(dict_c)):
	print(dict_c[i])


N = int(input())
D = {}
for _ in range(N):
	s = input()
	if s in D:
		D[s] += 1
	else:
		D[s] = 1
m = max(D.values())
for (k, v) in sorted(D.items()):
	if v == m:
		print(k)


from collections import Counter
N = int(input())
S = [input() for i in range(N)]
s = Counter(S)
max_val = max(s.values())
ans = [k for (k, v) in s.items() if v == max_val]
ans.sort()
for x in ans:
	print(x)


import collections
N = int(input())
S = []
for i in range(N):
	s = input()
	S.append(s)
l = collections.Counter(S)
keys = l.keys()
k = max(l.values())
ans = []
for i in keys:
	if l[i] == k:
		ans.append(i)
ans.sort()
n = len(ans)
for i in range(n):
	print(ans[i])


N = int(input())
S = sorted([input() for _ in range(N)])
A = []
count = 1
for i in range(N - 1):
	if i == N - 2:
		A.append(S[N - 1])
	if S[i] != S[i + 1]:
		A.append(S[i])
A.sort()
B = [1] * len(A)
a = 0
for i in range(N - 1):
	if S[i] == S[i + 1]:
		B[a] += 1
	else:
		a += 1
m = max(B)
for i in range(len(A)):
	if B[i] == m:
		print(A[i])


import collections

def i_input():
	return int(input())

def i_map():
	return list(map(int, input().split()))

def i_list():
	return list(map(int, input().split()))

def i_row(N):
	return [int(input()) for _ in range(N)]

def i_row_list(N):
	return [list(input().split()) for _ in range(N)]
n = i_input()
ss = [input() for _ in range(n)]
ss.sort()
css = collections.Counter()
for s in ss:
	css[s] += 1
maxapper = max(css.values())
for w in css:
	if css[w] == maxapper:
		print(w)


(_, *ss) = open(0).read().split()
from collections import Counter
c = Counter(ss)
mx = c.most_common(1)[0][1]
for s in sorted((key for (key, count) in c.items() if count == mx)):
	print(s)


n = int(input())
d = {}
for i in range(n):
	s = input()
	if s not in d:
		d.update({s: 1})
	else:
		d[s] += 1
max_val = max(d.values())
keys_of_max_val = [key for key in d if d[key] == max_val]
print('\n'.join(sorted(keys_of_max_val)))


def sovle():
	N = int(input())
	d = {}
	max = []
	max_count = 0
	for i in range(N):
		s = input()
		if s in d:
			d[s] += 1
		else:
			d[s] = 1
		if max_count < d[s]:
			max = [s]
			max_count = d[s]
		elif max_count == d[s]:
			max.append(s)
	max.sort()
	for i in max:
		print(i)
sovle()


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
m = max(c.values())
ans_list = [i for i in c.keys() if c[i] == m]
[print(ans) for ans in sorted(ans_list)]


n = int(input())
s = list((input() for i in range(n)))
import collections
A = collections.Counter(s)
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
for i in C:
	print(i)


import collections
N = int(input())
L = []
for i in range(N):
	L.append(input())
C = collections.Counter(L)
Max = C.most_common()[0][1]
l = [i[0] for i in C.items() if i[1] == Max]
print(*sorted(l), sep='\n')


import collections

def resolve():
	n = int(input())
	s = [input() for _ in range(n)]
	c = collections.Counter(s)
	max_count = c.most_common()[0][1]
	ans = [i[0] for i in c.items() if i[1] == max_count]
	for i in sorted(ans):
		print(i)
resolve()


d = dict()
for _ in range(int(input())):
	s = input()
	d[s] = d.get(s, 0) + 1
m = max(d.values())
i = [k for (k, v) in d.items() if v == m]
for v in sorted(i):
	print(v)


n = int(input())
d = {}
for _ in range(n):
	s = input()
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
mx = max(d.values())
for s in sorted((k for k in d if d[k] == mx)):
	print(s)


n = int(input())
A = []
for i in range(n):
	a = str(input())
	A.append(a)
import collections
c = collections.Counter(A)
ma = c.most_common()[0][1]
C = [i[0] for i in c.items() if i[1] >= ma]
C.sort(reverse=False)
for j in range(len(C)):
	print(C[j])


from collections import Counter as C
n = int(input())
ll = [input() for _ in [0] * n]
p = dict(C(ll))
i = max(p.values())
ld = [x for x in p if p[x] == i]
[print(x) for x in sorted(ld)]


N = int(input())
A = {}
for i in range(N):
	s = input()
	if s in A:
		A[s] += 1
	else:
		A[s] = 1
s_max = max(A.values())
for j in sorted((k for k in A if A[k] == s_max)):
	print(j)


N = int(input())
d = dict()
A = []
ma = 0
for i in range(N):
	s = input()
	if s not in d:
		d[s] = 0
	d[s] += 1
ma = max(d.values())
for (i, j) in sorted(d.items()):
	if j == ma:
		print(i)


from collections import *
(_, *a) = map(lambda x: x.rstrip(), open(0))
a = Counter(a).most_common()
a = sorted([i[0] for i in a if i[1] == a[0][1]])
print(*a, sep='\n')


import collections
N = int(input())
s = [str(input()) for i in range(N)]
c = collections.Counter(s)
maximum = max(c.values())
max_c_list = sorted((key for (key, value) in c.items() if value == maximum))
for s in max_c_list:
	print(s)


n = int(input())
d = {}
for i in range(n):
	j = input()
	if j not in d:
		d[j] = 1
	else:
		d[j] += 1
n = d[max(d, key=d.get)]
l = [k for (k, v) in d.items() if v == n]
print(' '.join(sorted(l)))


N = input()
Ws = {}
for i in range(int(N)):
	a = input()
	if a in Ws.keys():
		Ws[a] += 1
	else:
		Ws[a] = 0
m = max(Ws.values())
for i in sorted([k for (k, v) in Ws.items() if v == m]):
	print(i)


from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
	d[input()] += 1
mx = max(d.values())
print('\n'.join(sorted([k for k in d.keys() if d[k] == mx])))


N = int(input())
S = [input() for _ in range(N)]
dict_s = dict()
for s in S:
	if s in dict_s:
		dict_s[s] += 1
	else:
		dict_s[s] = 1
sorted_s = sorted(dict_s.items(), key=lambda x: x[1], reverse=True)
max_s = []
max_count = -1
for s in sorted_s:
	if s[1] >= max_count:
		max_s.append(s[0])
		max_count = s[1]
for s in sorted(max_s):
	print(s)


n = int(input())
d = {}
a = []
for i in range(n):
	s = input()
	if s not in d:
		d[s] = 1
		a.append(s)
	else:
		d[s] += 1
m = max(d.values())
a.sort()
for i in a:
	if d[i] == m:
		print(i)


from collections import Counter
n = int(input())
s = []
for _ in range(n):
	s.append(input())
s.sort()
c = Counter(s)
values = sorted(list(c.values()), reverse=True)
keys = sorted(list(c.keys()))
for item in c:
	if c[item] == values[0]:
		print(item)


N = int(input())
import collections
List = [input() for i in range(N)]
A = collections.Counter(List)
m = max(A.values())
X = [i for (i, value) in A.items() if value == m]
Y = sorted(X)
for Z in Y:
	print(Z)


from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word).most_common()
u = s[0][1]
v = []
for (i, j) in s:
	if j == u:
		v.append(i)
v.sort()
print(*v)


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cs = Counter(s).most_common()
m = cs[0][1]
ms = [i for i in cs if i[1] == m]
for i in sorted(ms):
	print(i[0])


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())
X = [input().strip() for i in range(N)]
cc = collections.Counter(X)
maximum = max(cc.values())
ans = sorted([ss[0] for ss in cc.items() if ss[1] == maximum])
print(*ans)


import os, sys, re, math
N = int(input())
S = []
for i in range(N):
	S.append(input())
d = {}
for s in S:
	if not s in d:
		d[s] = 0
	d[s] += 1
d = sorted(list(d.items()), key=lambda x: x[1], reverse=True)
names = [v[0] for v in d if v[1] == d[0][1]]
for name in sorted(names):
	print(name)


N = int(input())
D = {}
for n in range(N):
	S = input()
	D[S] = D.get(S, 0) + 1
L = max(D.values())
for (k, v) in sorted(D.items()):
	if v == L:
		print(k)


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')


from collections import Counter
n = int(input())
s = list((input() for i in range(n)))
c = Counter(s)
m = max(c.values())
s = sorted(list(set(s)))
for i in range(len(s)):
	if c[s[i]] == m:
		print(s[i])


import collections as c
a = c.Counter((input() for _ in range(int(input()))))
b = a.most_common(1)[0][1]
print(*sorted([i for (i, j) in a.items() if j == b]), sep='\n')


N = int(input())
S = []
for i in range(N):
	S.append(str(input()))
S.sort()
S.append(0)
prev_name = S[0]
cnt = 1
names = []
cnts = []
for i in range(1, N + 1):
	if prev_name == S[i]:
		cnt += 1
	else:
		names.append(prev_name)
		cnts.append(cnt)
		prev_name = S[i]
		cnt = 1
max_cnt = max(cnts)
for i in range(len(names)):
	if cnts[i] == max_cnt:
		print(names[i])


from collections import Counter
N = int(input())
A = [input() for i in range(N)]
c = Counter(A).most_common()
(k, v) = zip(*c)
[print(s) for s in sorted(k[:v.count(v[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 *
(n, *s) = open(0)
c = Counter(s)
mc = c.most_common()
ans = sorted((s * (t == mc[0][1]) for (s, t) in mc))
for a in ans:
	print(a, end='')


n = int(input())
x = {}
for i in range(n):
	s = input()
	if s in x:
		x[s] += 1
	else:
		x[s] = 0
m = max((x[i] for i in x))
q = []
for i in x:
	if x[i] == m:
		q.append(i)
print(*sorted(q), sep='\n')


from collections import Counter
n = int(input())
s = Counter([input() for _ in [0] * n])
m = s.most_common(1)[0][1]
r = sorted((k for (k, v) in s.items() if v == m))
for a in r:
	print(a)


from collections import Counter
n = int(input())
ss = [input() for _ in range(n)]
ss.sort()
c = Counter()
mc = 0
for s in ss:
	c[s] += 1
	mc = max(mc, c[s])
seen = set()
for s in ss:
	if c[s] == mc and s not in seen:
		print(s)
		seen.add(s)


import collections
N = int(input())
S = [input() for i in range(N)]
A = []
P = collections.Counter(S)
y = max(P.values())
A = [k for (k, v) in P.items() if v == y]
A.sort()
for List in A:
	print(List)


N = int(input())
S = {}
for n in range(N):
	s = input()
	S[s] = S.get(s, 0) + 1
S = sorted(S.items(), key=lambda x: (-x[1], x[0]))
maxS = S[0][1]
for (s, cnt) in S:
	if cnt != maxS:
		break
	print(s)


N = int(input())
dic = dict()
for n in range(N):
	key = input()
	dic[key] = dic.get(key, 0) + 1
m = max(dic.values())
keys = [k for (k, v) in dic.items() if v == m]
for k in sorted(keys):
	print(k)


from collections import Counter
n = int(input())
a = [input() for x in range(n)]
b = Counter(a)
c = max(b.values())
s = [s for (s, g) in b.items() if g == c]
s.sort()
print('\n'.join(s))


from collections import Counter
n = int(input())
L = [input() for i in range(n)]
C = Counter(L)
maxv = max(C.values())
A = [k for (k, v) in C.items() if v == maxv]
A.sort()
print('\n'.join(A))


n = int(input())
l = {}
a = 0
for i in range(n):
	s = input()
	if s in l:
		l[s] += 1
	else:
		l[s] = 1
	if a < l[s]:
		a = l[s]
ans = []
for i in list(l.keys()):
	if l[i] == a:
		ans.append(i)
ans.sort()
for j in ans:
	print(j)


N = int(input())
d = {}
for i in range(N):
	s = input()
	if s in d.keys():
		d[s] += 1
	else:
		d[s] = 1
M = max(d.values())
for (j, k) in sorted(d.items()):
	if k == M:
		print(j)


import collections
N = int(input())
S = []
for i in range(N):
	S.append(str(input()))
A = collections.Counter(S)
m = max(A.values())
for s in sorted(set(S)):
	if A[s] == m:
		print(s)


N = int(input())
cnt = {}
for _ in range(N):
	s = input()
	if s not in cnt:
		cnt[s] = 0
	cnt[s] += 1
max_val = max([cnt[v] for v in cnt])
l = [v for v in cnt if cnt[v] == max_val]
l.sort()
print('\n'.join(l))


N = int(input())
dic = {}
max_count = 1
for i in range(N):
	s = input()
	if s not in dic:
		dic[s] = 1
	else:
		dic[s] += 1
		if max_count < dic[s]:
			max_count = dic[s]
ans_lis = []
for (i, j) in dic.items():
	if j == max_count:
		ans_lis.append(i)
ans_lis.sort()
for i in ans_lis:
	print(i)


n = int(input())
S = [input() for _ in range(n)]
from collections import Counter
d = Counter(S)
e = []
c = d.most_common()[0][1]
for i in d.keys():
	if d[i] == c:
		e.append(i)
e.sort()
print(*e, sep='\n')


n = int(input())
l = {}
max = 0
for _ in range(n):
	s = input()
	l[s] = l.get(s, 0) + 1
	if max < l[s]:
		max = l[s]
for i in sorted(list(filter(lambda s: l[s] == max, l.keys()))):
	print(i)


c = {}
N = int(input())
for i in range(N):
	s = input()
	if s not in c:
		c[s] = 1
	else:
		c[s] += 1
n = max(c.values())
L = list()
for i in c:
	if c[i] == n:
		L.append(i)
L = sorted(L)
for i in L:
	print(i)


N = int(input())
A = {}
MAX = 0
for i in range(N):
	s = input()
	A[s] = A.get(s, 0) + 1
	MAX = max(MAX, A[s])
B = sorted(A.items())
for (k, v) in B:
	if v == MAX:
		print(k)


from collections import defaultdict
N = int(input())
S = defaultdict(int)
for i in range(N):
	S[input()] += 1
m = max(S.values())
for s in sorted(filter(lambda x: S[x] == m, S)):
	print(s)


import collections
n = int(input())
c = {}
for _ in range(n):
	s = input()
	c[s] = c.get(s, 0) + 1
u = max(c.values())
print('\n'.join(sorted([k for (k, v) in c.items() if v == u])))


from collections import Counter
n = int(input())
s = [str(input()) for _ in range(n)]
num = Counter(s)
ans = []
ma = max(num.values())
for i in sorted(num):
	if num[i] == ma:
		print(i)


from collections import Counter
import heapq
n = int(input())
sc = Counter()
for x in range(n):
	s = input()
	sc.update([s])
max_num = sc.most_common()[0][1]
q = []
for v in list(sc.items()):
	if v[1] == max_num:
		heapq.heappush(q, v[0])
for _ in range(len(q)):
	print(heapq.heappop(q))


N = int(input())
S = {}
for n in range(N):
	s = input()
	S[s] = S.get(s, 0) + 1
maxS = max(S.values())
S = [k for (k, v) in S.items() if v == maxS]
print('\n'.join(sorted(S)))


import collections
N = int(input())
C = collections.Counter([input() for _ in range(N)])
(v, c) = zip(*C.most_common())
[print(x) for x in sorted([v[i] for i in range(len(c)) if c[i] == c[0]])]


import collections
N = int(input())
S = []
for _ in range(N):
	S += [input()]
d = collections.Counter(S).most_common()
for i in sorted([k for (k, v) in d if v == d[0][1]]):
	print(i)


def N():
	return int(input())

def L():
	return list(map(int, input().split()))

def NL(n):
	return [list(map(int, input().split())) for i in range(n)]
mod = pow(10, 9) + 7
import sys
import math
import collections
n = N()
s = {}
for i in range(n):
	a = input()
	if a in s:
		s[a] += 1
	else:
		s[a] = 1
s = sorted(s.items(), key=lambda x: x[1], reverse=True)
m = s[0][1]
s2 = []
for i in range(len(s)):
	if s[i][1] == m:
		s2.append(s[i][0])
	else:
		break
s2.sort()
for i in s2:
	print(i)


N = int(input())
dic = {}
for i in range(N):
	s = str(input())
	if s in dic:
		dic[s] += 1
	else:
		dic[s] = 1
S = sorted(dic.values())
t = S[-1]
X = []
for key in dic:
	if dic[key] == t:
		X.append(key)
x = sorted(X)
for i in range(len(X)):
	print(x[i])


N = int(input())
S = [input() for _ in range(N)]
S.sort()
res = 0
cnt = 1
for i in range(N - 1):
	if S[i] == S[i + 1]:
		cnt += 1
	else:
		res = max(res, cnt)
		cnt = 1
res = max(res, cnt)
cnt = 1
ans = []
for i in range(N - 1):
	if S[i] == S[i + 1]:
		cnt += 1
	else:
		if res == cnt:
			ans.append(S[i])
		cnt = 1
if cnt == res:
	ans.append(S[i + 1])
for i in range(len(ans)):
	print(ans[i])


import collections
(N, *S) = open(0).read().split()
C = collections.Counter(S)
i = C.most_common()[0][1]
print(*sorted([k for (k, v) in C.most_common() if v == i]), sep='\n')


from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
	dic[input()] += 1
tmp = [(key, value) for (key, value) in dic.items()]
tmp.sort(key=lambda x: (x[1], x[0]))
m = tmp[-1][1]
for i in range(len(dic)):
	if tmp[i][1] == m:
		print(tmp[i][0])


import collections
n = int(input())
ans = list((input() for i in range(n)))
ans = collections.Counter(ans)
m = max(ans.values())
keys = [k for (k, v) in ans.items() if v == m]
[print(j) for j in sorted(keys)]


N = int(input())
d = {}
for _ in range(N):
	s = input()
	if s not in d.keys():
		d[s] = 1
	else:
		d[s] += 1
max_n = max(d.values())
ans = []
for (key, value) in d.items():
	if value == max_n:
		ans.append(key)
ans.sort()
for i in ans:
	print(i)


import collections
n = int(input())
s = [input() for i in range(n)]
li = collections.Counter(s)
ma = max(li.values())
ans = [i for (i, j) in li.items() if j == ma]
print('\n'.join(sorted(ans)))


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)


N = int(input())
S = []
for i in range(N):
	S.append(input())
S_set = set(S)
S_sorted = sorted(S)
S_sorted.append('null0')
cntlist = [[S_sorted[0], 1]]
j = 0
for i in range(len(S) - 1):
	if cntlist[j][0] != S_sorted[i + 1]:
		cntlist.append([S_sorted[i + 1], 1])
		j = j + 1
	else:
		cntlist[j][1] += 1
maxnum = 0
for i in range(len(cntlist)):
	maxnum = max(cntlist[i][1], maxnum)
cntlist_new = []
for i in range(len(cntlist)):
	if cntlist[i][1] == maxnum:
		cntlist_new.append(cntlist[i])
from operator import itemgetter
new_cnt = sorted(cntlist_new, key=itemgetter(0), reverse=False)
for i in range(len(new_cnt)):
	print(new_cnt[i][0])


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s = Counter(s)
s = sorted(list(s.items()), reverse=True, key=lambda x: x[1])
max_count = max(list([x[1] for x in s]))
ans = sorted([l for (l, c) in s if c == max_count])
for a in ans:
	print(a)


from collections import Counter
N = int(input())
S = Counter([input() for i in range(N)])
k = max(S.values())
A = []
for s in S:
	if S[s] == k:
		A.append(s)
A.sort()
for a in A:
	print(a)


from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
freq = max(C.values())
M = [kv[0] for kv in C.items() if kv[1] == freq]
M.sort()
A = '\n'.join(M)
print(A)


import collections
n = int(input())
names = [input() for _ in range(n)]
c = collections.Counter(names)
maxv = max(c.values())
ans = []
for i in c.items():
	if i[1] == maxv:
		ans.append(i[0])
ans = sorted(ans)
for i in ans:
	print(i)


import collections
N = int(input())
Slist = []
for i in range(N):
	Slist.append(input())
anslist = sorted(Slist)
c = collections.Counter(anslist)
(values, counts) = zip(*c.most_common())
maxcount = counts[0]
i = 0
for i in range(len(values)):
	if maxcount == counts[i]:
		print(values[i])
		maxcount = counts[i]
		i += 1
	else:
		break


n = int(input())
dct = {}
for i in range(n):
	s = input()
	if s in dct:
		dct[s] += 1
	else:
		dct[s] = 1
max_num = max(dct.values())
ans = []
sorted_dct = sorted(dct.items())
for x in sorted_dct:
	if x[1] >= max_num:
		ans.append(x[0])
print(*ans, sep='\n')


n = int(input())
s = [input() for i in range(n)]
dic = {}
for i in range(n):
	if s[i] in dic.keys():
		dic[s[i]] += 1
	else:
		dic[s[i]] = 1
max1 = max(dic.values())
ans = []
for keys in dic.keys():
	if dic[keys] == max1:
		ans.append(keys)
ans.sort()
for i in ans:
	print(i)


from collections import Counter
n = int(input())
a = [input() for i in range(n)]
cnt = Counter(a)
l = max(cnt.values())
ans = [s for (s, c) in cnt.items() if c == l]
ans.sort()
print('\n'.join(ans))


N = int(input())
S = dict()
for i in range(N):
	s = input()
	if s in S:
		S[s] += 1
	else:
		S[s] = 1
max_val = max(S.values())
max_key = [key for key in S if S[key] == max_val]
print('\n'.join(sorted(max_key)))


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)


from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
l = Counter(S)
MAXNUM = max(l.values())
for s in sorted(list(set(S))):
	if l[s] == MAXNUM:
		print(s)


from collections import *
(n, *s) = open(0)
c = Counter(s).most_common()
print(*sorted((t for (t, i) in c if i == c[0][1])))


n = int(input())
d = {}
for i in range(n):
	st = input()
	if st in list(d.keys()):
		d[st] += 1
	else:
		d[st] = 1
m = max(list(d.values()))
l = []
for (x, y) in list(d.items()):
	if y == m:
		l.append(x)
l.sort()
for v in l:
	print(v)


box = {}
n = int(input())
for i in range(n):
	v = input()
	if v in box:
		box[v] += 1
	else:
		box[v] = 1
m = max(box.values())
f = [k for (k, v) in box.items() if v == m]
f.sort()
print('\n'.join(f))


n = int(input())
d = {}
for _ in range(n):
	s = input()
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
t = max(d.values())
for (x, y) in sorted(d.items()):
	if y == t:
		print(x)