Harryxun/stf_run huggingface dataset:
N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N - 1)]
P = [list(map(int, input().split())) for _ in range(Q)]

tree = [[] for _ in range(N + 1)]
for a, b in X:
    tree[a].append(b)

def dfs(u, x):
    ctr[u] += x
    for v in tree[u]:
        dfs(v, x)

ctr = [0] * (N + 1)
for p, x in P:
    dfs(p, x)
    
print(*ctr[1:])


### FIXED CODE ###

from collections import deque

N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)

ctr = [0] * (N + 1)
for p, x in Y:
    ctr[p] += x

# BFS
visited = [False] * (N + 1)
visited[1] = True
q = deque([1])
while q:
    u = q.popleft()
    for v in graph[u]:
        if visited[v]:
            continue
            
        ctr[v] += ctr[u]
        visited[v] = True
        q.append(v)
        
print(*ctr[1:])
import sys
sys.setrecursionlimit(10**7)
mo=10**9+7

n,k=map(int,input().split())

def P(n,k,mo):
    rt=1
    for i in range(k):
        rt*=(n-i)
        rt%=mo
    return rt

g=[[] for i in range(1+n)]
v=[0]*(1+n)
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)

def dfs(cur):
    c=sum([v[i]!=1 for i in g[cur]])
    if c==0:
        return
    v[cur]=1
    ans[0]*=P(k-2,c,mo)
    for nb in g[cur]:
        if v[nb]!=1:
            dfs(nb)
v[1]=1
ans=[P(k,1+len(g[1]),mo)]

for j in g[1]:
    c=sum([v[i]!=1 for i in g[j]])
    ans*=P(k-2,c,mo)
    dfs(j)
print(ans[0]%mo)


### FIXED CODE ###

mo=10**9+7
n,k=map(int,input().split())

def P(n,k,mo):
    rt=1
    for i in range(k):
        rt*=(n-i)
        rt%=mo
    return rt

g=[[] for i in range(1+n)]
v=[0]*(1+n)

for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)

def dfs(cur):
    q=[]
    q.append(cur)

    while q:
        cur=q.pop()
        v[cur]=1
        c=len(g[cur])-1
        ans[0]*=P(k-2,c,mo)
        
        for nb in g[cur]:
            if v[nb]!=1:
                q.append(nb)
v[1]=1
ans=[P(k,1+len(g[1]),mo)]

for j in g[1]:
    dfs(j)
print(ans[0]%mo)
N = int(input())
s = [int(input()) for i in range(N)]

s_max=s.pop(max(s))
s_max2=s.pop(max(s))

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)


### FIXED CODE ###

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

temp=s.copy()
s_max=max(temp)
temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
    print(s_max2)
n=input()
sm=0
for i in n:
  sm+=int(i)
return sm%9

### FIXED CODE ###

n=int(input())
if n%9==0:
  print("Yes")
else:
  print("No")
n=int(input())
a=list(map(int,input().split()))
x,y=sum(x%2==0 for x in l),n-x
print(3**n-2**x)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
e=sum(x%2==0 for x in a)
print(3**n-2**e)
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(input())
#S=input()
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
h=list(map(int,input().split()))
#v=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
h.reverse()
cnt=0
ans=[]
for i in range(n-1):
    if h[i]<=h[i+1]:
        cnt+=1
    else:
        ans.append(cnt)
        cnt=0
print(max(max(ans),0))

### FIXED CODE ###

#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(input())
#S=input()
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
h=list(map(int,input().split()))
#v=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
h.reverse()
cnt=0
ans=0
for i in range(1,n):
    if h[i-1]<=h[i]:
        cnt+=1
    else:
        cnt=0
    ans=max(ans,cnt)
print(ans)
N,K = map(int,input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int,input().split()))

ans = max(C)
for i in range(N):
    s = i
    l = [C[i]]
    while:
        s = P[s]
        if s == i:
            break
        l.append(C[s])
        

    if sum(l) > 0:
        c = K//len(l)*sum(l)
        n = K%len(l)
        ans = max(ans,c)
        s = i
        for j in range(n):
            c += C[s]
            s = P[s]
            ans = max(ans,c)

    n = min(N,K)
    s = i
    c = 0
    for j in range(n):
        c += C[s]
        s = P[s]
        ans = max(ans,c)
            
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int,input().split()))

ans = max(C)
for i in range(N):
    s = i
    l = [C[i]]
    while True:
        s = P[s]
        if s == i:
            break
        l.append(C[s])
        

    if sum(l) > 0:
        if K>=len(l):
            c = (K//len(l)-1)*sum(l)
            n = K%len(l)+len(l)
        else:
            c = 0
            n = K
        ans = max(ans,c)
        s = i
        for j in range(n):
            c += C[s]
            s = P[s]
            ans = max(ans,c)

    n = min(N,K)
    s = i
    c = 0
    for j in range(n):
        c += C[s]
        s = P[s]
        ans = max(ans,c)
            
print(ans)
N = int(input())
X = input()
memo = {}
X_int = int(X, 2)


def popcount(n: int):
    x = bin(n)[2:]
    return x.count("1")


pcf = popcount(int(X, 2))
pcm = pcf - 1
pcp = pcf + 1
xm = X_int % pcm
xp = X_int % pcp


def f(n: int, ops: int):

    while n != 0:
        n %= popcount(n)
        ops += 1
    return ops


def rev(x: str, i: int):
    if x == "1":
        n = (xm - (pow(2, N-i-1, pcm))) % pcm
    else:
        n = (xp + (pow(2, N-i-1, pcp))) % pcp
    return n


if __name__ == "__main__":
    for i, x in enumerate(X):
        print(f(rev(x, i), 1))


### FIXED CODE ###

N = int(input())
X = input()
memo = {}
X_int = int(X, 2)


def popcount(n: int):
    x = bin(n)[2:]
    return x.count("1")


pcf = popcount(int(X, 2))
pcm = pcf - 1
pcp = pcf + 1
xm = X_int % pcm if pcm != 0 else 0
xp = X_int % pcp


def f(n: int, ops: int):

    while n != 0:
        n %= popcount(n)
        ops += 1
    return ops


def rev(x: str, i: int):
    if x == "1":
        if pcm == 0:
            return -1
        n = (xm - (pow(2, N-i-1, pcm))) % pcm
    else:
        n = (xp + (pow(2, N-i-1, pcp))) % pcp
    return n


if __name__ == "__main__":
    for i, x in enumerate(X):
        n = rev(x, i)
        if n == -1:
            print(0)
        else:
            print(f(n, 1))
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
ans = int(0)
x = int(0)
y = int(0)

As = sorted(A)

if As[0]>0:
    for i in range(N):
        ans += As[i]

    ans -=As[0]*2
    print(ans)

    x = As[0]
    for i in range(N-2):
        y = As[i+1]
        print(x,y)
        x = x - y

    y = x
    x = As[N-1]
    print(x,y)

elif As[N-1]<0:
    for i in range(N):
        As[i] *= -1
    for i in range(N):
        ans += As[i]

    ans -=As[N-1]*2
    print(ans)

    As = sorted(As)

    x = As[0]
    for i in range(N-2):
        y = As[i+1]
        print(-x,-y)
        x = x - y

    y = x
    x = As[N-1]
    print(-y,-x)

##################################
else:
    for i in range(N):
        ans += abs(As[i])

    print(ans)

    x = As[0]
    i = int(0)
    while(i<N-2 and A[N-i-1]>0):
        y = As[N-i-1]
        print(x,y)
        x = x - y
        i +=1
#    print("ok")
    y = x
    while(i<N-2):
        x = As[i]
        print(x,y)
        y = x - y
        i +=1


    x = As[N-i]
    print(x,y)


### FIXED CODE ###

def examC():
    N = I()
    A = LI()
    negative = []; positive = []
    ans = 0; ansC = []
    for i in A:
        if i<0:
            negative.append(i)
        else:
            positive.append(i)
    if negative==[]:
        positive.sort()
        if N>2:
            cur = positive[0] - positive[1]
            ansC.append([positive[0], positive[1]])
            ans = sum(positive) - 2 * positive[0]
            for i in range(2, N - 1):
                ansC.append([cur, positive[i]])
                cur -= positive[i]
            ansC.append([positive[N - 1], cur])
        else:
            ansC.append([positive[1],positive[0]])
            ans = positive[1]-positive[0]

    elif positive==[]:
        negative.sort(reverse=True)
        cur = negative[0] - negative[1]
        ansC.append([negative[0],negative[1]])
        ans = -sum(negative)+2*negative[0]
        for i in range(2,N):
            ansC.append([cur,negative[i]])
            cur -=negative[i]
    else:
        positive.sort()
        negative.sort(reverse=True)
        ans = sum(positive) - sum(negative)
        curN = negative[0]
        curP = positive[0]
        for i in range(len(positive)-1):
            ansC.append([curN,positive[i+1]])
            curN -=positive[i+1]
        for i in range(len(negative)-1):
            ansC.append([curP,negative[i+1]])
            curP -=negative[i+1]
        ansC.append([curP,curN])

    print(ans)
    for v in ansC:
        print(" ".join(map(str,v)))

from string import digits
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()
q, k = list(map(int, input().split()))
list = [int(i) for i in input()]

# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)

if len(sum01) % 2 == 1:
    sum01.append(0)

# print(sum01)
Add = 2 * k + 1
ruiseki = [0]
for i, e in enumerate(sum01):
    ruiseki.append(ruiseki[i] + sum01[i])

# print(ruiseki)
answer = 0
for i in range(0, len(ruiseki), 2):
    left = i
    right = min(i + Add, len(sum01))
    temp = ruiseki[right] - ruiseki[left]
    answer = max(temp, answer)

### FIXED CODE ###

n = list(map(int, input().split()))
if n[0] == n[1]:
    print(n[0] * 2)
else:
    print(max(n) + max(n) - 1)
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a,reverse=True)
x,y=b[0],b[1]
z=a.index(x)
for i in range(n):
	if i==z:
		print(y)
	else:
		print(x)

### FIXED CODE ###

print(3*(int(input())**2))
N,K = map(int, input().split())

ans1 = N - K + 1
ans2 = ans1 * (ans1 - 1)
ans3 = 1

# combination(N,K)を求める
for i in range(K):
    ans3 *= (N - i)

ans3 = int(ans3 / 6 - ans1 - ans2 )

print(ans1 % (10**9 + 7))
print(ans2 % (10**9 + 7))
print(ans3 % (10**9 + 7))

### FIXED CODE ###

from scipy.misc import comb

N,K = map(int, input().split())

red_ball_count = N - K

for i in range(1, K + 1):
    if red_ball_count + 1 - i < 0:
        print(0)
    else:
        print(comb(red_ball_count + 1, i, exact=True) * comb(K - 1, i - 1, exact=True) % (10**9 + 7))
import sys
sys.setrecursionlimit(2147483647)

n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
  a, b = map(int, input().split())
  edges[a - 1].append(b - 1)
  edges[b - 1].append(a - 1)


vertice = [0 for _ in range(n)]


def dfs(v, color_i):
    vertice[v] = color_i
    for i in edges[v]:
        if vertice[i] == 0:
            dfs(i, color_i*(-1))

dfs(0, 1)

ans = []
if vertice.count(1) <= n // 3:
    not3 = [i for i in range(1, n+1) if i % 3 != 0]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == 1:
            if num3:
                ans.append(str(num3.pop()))
                continue
        ans.append(str(not3.pop()))
elif vertice.count(-1) <= n // 3:
    not3 = [i for i in range(1, n+1) if i % 3 != 0]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == -1:
            if num3:
                ans.append(str(num3.pop()))
                continue
        ans.append(str(not3.pop()))
else:
    num1 = [i for i in range(1, n+1) if i % 3 == 1]
    num2 = [i for i in range(1, n+1) if i % 3 == 2]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == 1:
            if num1:
                ans.append(str(num1.pop()))
            else:
                ans.append(str(num3.pop()))
        else:
            if num2:
                ans.append(str(num2.pop()))
            else:
                ans.append(str(num3.pop()))

print(" ".join(ans))


### FIXED CODE ###

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
 
group = [False] * n
parent = list(range(n))
stack = [0]
while stack:
  v = stack.pop()
  while edge[v]:
    u = edge[v].pop()
    if parent[v] != u:
      group[u] = not group[v]
      parent[u] = v
      stack.append(u)
 
three = 3
p = [0] * n
if group.count(False) <= n // 3:
  other = 1
  for i in range(n):
    if group[i] and other <= n:
      p[i] = other
      other += other % 3
    else:
      p[i] = three
      three += 3
elif group.count(True) <= n // 3:
  other = 1
  for i in range(n):
    if not group[i] and other <= n:
      p[i] = other
      other += other % 3
    else:
      p[i] = three
      three += 3
else:
  one, two = 1, 2
  for i in range(n):
    if group[i] and one <= n:
      p[i] = one
      one += 3
    elif not group[i] and two <= n:
      p[i] = two
      two += 3
    else:
      p[i] = three
      three += 3
print(' '.join(map(str, p)))
N = int(input())
A = list(map(int, input().split()))
import numpy as np
ans = np.prod(A)

if ans<= 10**18:
    print(ans)
    exit(0)
else:
    print(-1)


### FIXED CODE ###

A, B = map(int,input().split())
print(A*B)
import sys

N=input()
A=map(int, sys.stdin.readline().split())
A.sort()

L=[]
for i in range(N-1):
	if i==0:
		next=A[i]-A[i+1]
		L.append( (A[i], A[i+1]) )

	else:
		if i==N-2:
			L.append( (A[i+1],next) )
			ans=A[i+1]-next
		else:
			L.append( (next, A[i+1]) )
			next=next-A[i+1]
else:
	print ans
	for x, y in L:
		print x,y


### FIXED CODE ###

import sys

N=input()
A=map(int, sys.stdin.readline().split())
A.sort()
min_A=A[0]
max_A=A[-1]

L=[]
for i in range(1,N-1):
	v=A[i]
	if v<0:
		L.append( (max_A, v) )
		max_A-=v
	else:
		L.append( (min_A, v) )
		min_A-=v
else:
	L.append( (max_A,min_A) )
	print max_A-min_A
	for x,y in L:
		print x,y
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [1 for _ in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    l[b - 1] = 0
  elif:
    l[a - 1] = 0
  else:
    l[a - 1] = 0
    l[b - 1] = 0

cnt = 0
for i in l:
  if i == 1:
    cnt += 1

print(cnt)

### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [1 for _ in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    l[b - 1] = 0
  elif h[a-1] < h[b-1]:
    l[a - 1] = 0
  else:
    l[a - 1] = 0
    l[b - 1] = 0

cnt = 0
for i in l:
  if i == 1:
    cnt += 1

print(cnt)
a = int(input())
b = int(input())
c=a*b
if c % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
c = a * b
if c % 2 == 0:
  print("Even")
else:
  print("Odd")
N = int(input())
X = list(map(int, input().split()))

HP = []
for p in range(1, 101, 1):
    P = [p] * len(X)
    delta = sum([(i - j) ** 2 for (i, j) in zip(X, P)])
    HP.append(delta)

print(min(HP))


### FIXED CODE ###

N, A, B = map(int, input().split())
S = str(input())

AB = A + B

count_all = 0
count_abroad = 0
for i in range(N):
    if S[i] == "a" and count_all < AB:
        count_all += 1
        print("Yes")

    elif S[i] == "b" and count_abroad < B and count_all <AB:
        count_all += 1
        count_abroad += 1
        print("Yes")

    else:
        print("No")
N, M = map(int, input().split(" "))
A = [int(a) for a in input().split()]

tmp=0
B=[0]
for i in A:
    tmp += A[i]
    tmp = tmp % M
    B.append(tmp)

B.sort()
print (B)
cnt=0
ret=0
for i in range(len(B)):
    if i ==0:
        cnt += 1
        prev=B[0]
        
    else:
        if B[i] == prev:
            cnt += 1
            
        else:
            ret += int(cnt*(cnt-1)/2)
            prev = B[i]
            cnt = 1

ret += int(cnt*(cnt-1)/2)

print (ret)

### FIXED CODE ###

N, K = map(int, input().split(" "))
if N % K ==0:
    print (0)
else:
    print(1)
_ = input()
a, b = input().split()

result = ""

for a_, b_ in zip(a, b):
	result += a_ + b+

print(result)


### FIXED CODE ###

_ = input()
a, b = input().split()
 
result = ""
 
for a_, b_ in zip(a, b):
	result += a_ + b_
 
print(result)
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(1000000)

def preDatasets():
	datas = sys.stdin.readlines()
	for i in range(len(datas)):
		datas[i] = datas[i].strip('\n')
	return datas

def dfs(x, y, sym):
	tile[x][y] = '.'
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if(nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			if not tile[i][j] == '.':
				if tile[i][j] == '@':
					dfs(i, j, '@')
					res += 1
				elif tile[i][j] == '#':
					dfs(i, j, '#')
					res += 1
				elif tile[i][j] == '*':
					dfs(i, j, '*')
					res += 1
	print(res)

index = 0	
while True:
	datas = preDatasets()
	DX = [-1, 0, 1, 0]
	DY = [0, -1, 0, 1]

	N = int(datas[index].split(' ')[0])
	M = int(datas[index].split(' ')[1])
	tile = [[0 for i in range(N)]for j in range(M)]
	
	for i in range(len(tile)):
		tile[i] = list(datas[index+i+1])
	print(tile)

	if N == 0:
		break
	else:
		solve()
		index += N+1

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(M)] for j in range(N)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	counter += 1
	if counter-1 is N:
		solve()
		counter = 0
a,b,c =map(int,input().sprit())

count = 0:
for x in range(a, b + 1)
    if c % x == 0:
    # print(x,"ha ", c, "no yakusuu")
    count += 1
    	
print(count)

### FIXED CODE ###

a, b, c = map(int, input().split())

count = 0
for x in range(a, b + 1):
    if c % x == 0:
        count += 1
    	
print(count)
d, g = (int(i) for i in input().split())
p = [[int(i) for i in input().split()] for i in range(n)]
ans = 1000

for i in range(1 << d): # 4
    score = 0
    num = 0
    rest = 0
    for j in range(d): # 2
        if ((i >> j) & 1) == 1: # 0 1  2=10
            score += p[j][0] * 100 * (j + 1) + p[j][1]
            num += p[j][0]
        else:
            rest = j
    if score < g:
        need = (g - score) // (100*(rest+1))
        if need > p[rest][0] - 1: # 0だったところの中で一番大きいところの問題数-1よりも必要手数が多かったら初めに戻る
            continue
        else:
            num += need
    ans = min(ans, num)
print(ans)

### FIXED CODE ###

d, g = (int(i) for i in input().split())
p = [[int(i) for i in input().split()] for i in range(d)]
ans = 1000

for i in range(1 << d): # 4
    score = 0
    num = 0
    rest = 0
    for j in range(d): # 2
        if ((i >> j) & 1) == 1: # 0 1  2=10
            score += p[j][0] * 100 * (j + 1) + p[j][1]
            num += p[j][0]
        else:
            rest = j
    if score < g:
        need = (g - score - 1) // (100*(rest+1)) + 1
        if need > p[rest][0] - 1: # 0だったところの中で一番大きいところの問題数-1よりも必要手数が多かったら初めに戻る
            continue
        else:
            num += need
    ans = min(ans, num)
print(ans)
N = int(input())
lis = [input() for i in range(N)]

 
tmp_dic = {}
for s in lis:
    if s not in tmp_dic:
        tmp_dic[s] = 1
    else:
        tmp_dic[s] += 1
        
max_count = 0
for k,v in tmp_dic.items():
    max_count = max(v,max_count)
    
ans_lis = []
for k,v in tmp_dic.items():
    if v == max_count:
        ans_lis.append(k)
        
ans_lis.sort()
[print(f"{s}") for s in ans_lis]

### FIXED CODE ###

import collections

N = int(input())
cnt_dic = collections.defaultdict(int)

for _ in range(N):
  s = input()
  cnt_dic[s] += 1

max_v = max(cnt_dic.values())

ans_lis = [k for k, v in cnt_dic.items() if v == max_v]

for s in sorted(ans_lis):
  print(s)
import sys
sys.setrecursionlimit(3009)
s=input()
n=len(s)
t=input()
m=len(t)
def lcs(x,y):
	if min(x,y)==-1:
		return ""
	if s[x]==t[y]:
		return lcs(x-1,y-1)+s[x]
	a=lcs(x-1,y)
	b=lcs(x,y-1)
	if len(a)>len(b):
		return a
	else:
		return b
print(lcs(n-1,m-1))

### FIXED CODE ###

s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+1):
		if s[i-1]==t[j-1]:
			dp[i][j]=dp[i-1][j-1]+1
		else:
			dp[i][j]=max(dp[i-1][j],dp[i][j-1])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(input())
pn = list(map(int, input().split()))


def checkAllLess(tgt):
    for id in range(tgt):
        # print("id=" + str(id) + ", pn[]=" + str(pn[id]) + ", tgt=" + str(tgt))
        if(pn[id] < pn[tgt]):
            # print('False')
            return False
    # print('True')
    return True


cnt = 1
min = pn[0]
for i in range(n):
    if (min > i & & checkAllLess(i)):
        cnt += 1
    if (min > pn[i]):
        min = pn[i]
    # print(str(i) + ":" + str(cnt))

print(cnt)


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(input())
pn = list(map(int, input().split()))

cnt = 1
min = pn[0]
for i in range(1, n):
    if min > pn[i]:
        cnt += 1
        min = pn[i]

print(cnt)