N=int(eval(input()))

S={}

for n in range(N):

  s=eval(input())

  S[s]=S.get(s,0)+1



maxS=max(S.values())

S={k:v for k, v in list(S.items()) if v==maxS}

S=sorted(list(S.items()), key=lambda x:(-x[1],x[0]))

for k,cnt in S:

  print(k)

N=int(eval(input()))

S={}

for n in range(N):

  s=eval(input())

  S[s]=S.get(s,0)+1



maxS=max(S.values())

S=[k for k,v in list(S.items()) if v==maxS]

print(('\n'.join(sorted(S))))

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

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

-S = {k: v for k, v in list(S.items()) if v == maxS} -S = sorted(list(S.items()), key=lambda x: (-x[1], x[0])) -for k, cnt in S: -    print(k) +S = [k for k, v in list(S.items()) if v == maxS] +print(("\n".join(sorted(S))))