Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

# @author 

import sys

class EVirusTree2:

    def solve(self):
        from collections import defaultdict
        import sys
        sys.setrecursionlimit(10 ** 5 + 5)

        MOD = 10 ** 9 + 7

        n, k  = [int(_) for _ in input().split()]
        adj = defaultdict(list)
        for i in range(n - 1):
            a, b = [int(_) for _ in input().split()]
            a -= 1
            b -= 1
            adj[a].append(b)
            adj[b].append(a)

        done = [0] * n

        def dfs(s, rem):
            done[s] = 1
            if rem < 0:
                return 0
            res = 1
            for x in adj[s]:
                if done[x]:
                    continue
                if rem <= 0:
                    return 0
                res *= rem * dfs(x, k - 2)
                res %= MOD
                rem -= 1
                if res == 0:
                    return 0
            return res

        print((dfs(0, k - 1) * k) % MOD)




solver = EVirusTree2()
input = sys.stdin.readline

solver.solve()


### FIXED CODE ###

# @author 

import sys

class EVirusTree2:

    def solve(self):
        from collections import defaultdict
        import sys
        sys.setrecursionlimit(10 ** 5 + 5)

        MOD = 10 ** 9 + 7
        n, k  = [int(_) for _ in input().split()]
        adj = defaultdict(list)
        for i in range(n - 1):
            a, b = [int(_) for _ in input().split()]
            a -= 1
            b -= 1
            adj[a].append(b)
            adj[b].append(a)
        done = [0] * n
        def dfs(s, rem):
            done[s] = 1
            if rem < 0:
                return 0
            res = 1
            for x in adj[s]:
                if done[x]:
                    continue
                if rem <= 0:
                    return 0
                res = (res * rem) % MOD
                res = (res * dfs(x, k - 2)) % MOD
                rem -= 1
                if res == 0:
                    return 0
            return res

        print((dfs(0, k - 1) * k) % MOD)




solver = EVirusTree2()
input = sys.stdin.readline

solver.solve()
### BUGGY CODE ###

N,K=list(map(int,input().split()))
l=[0]*(K+1)
ans=0
mod=10**9+7

for x in range(0,K):
    x=K-x
    l[x]=(K//x)**N%mod
    for y in range(2*x,K+1,x):
        l[x]-=l[y]
        l[x]%=mod
    ans+=l[x]*x
    ans%=mod
print(ans)

### FIXED CODE ###

N,K=list(map(int,input().split()))
l=[0]*(K+1)
ans=0
mod=10**9+7

for x in range(K,0,-1):
    l[x]=pow((K//x),N,mod)
    for y in range(2*x,K+1,x):
        l[x]-=l[y]
        l[x]=pow(l[x],1,mod)
    ans+=l[x]*x
    ans=pow(ans,1,mod)
print(ans)
### BUGGY CODE ###

arr = []
cur = 0

q = int(input())
for i in range(q):
    op = list(map(int, input().split(' ')))
    if op[0] == 0:
        arr.insert(cur, op[1])
    elif op[0] == 1:
        cur += op[1]
    elif op[0] == 2:
        arr.pop(cur)

for ele in arr:
    print(ele)


### FIXED CODE ###

class Node:
    def __init__(self, val=None, prev=None, next=None):
        self.val = val
        self.prev = prev
        self.next = next

class DoublyLinkedList():
    def __init__(self):
        self.end = Node(val='END', prev=None, next=None)
        self.cur = self.end

    def insert(self, x):
        new_node = Node(val=x, prev=self.cur.prev, next=self.cur)
        if self.cur.prev != None: self.cur.prev.next = new_node
        self.cur.prev = new_node
        self.cur = new_node

    def move(self, d):
        if d > 0:
            for i in range(d):
                if self.cur.next == None: break
                self.cur = self.cur.next
        elif d < 0:
            for i in range(abs(d)):
                if self.cur.prev == None: break
                self.cur = self.cur.prev

    def erase(self):
        if self.cur == self.end: return
        if self.cur.prev != None: self.cur.prev.next = self.cur.next
        self.cur.next.prev = self.cur.prev
        self.cur = self.cur.next

    def print_elements(self):
        node_list = []
        crnode = self.end
        while True:
            if crnode.prev == None: break
            node_list.append(crnode.prev.val)
            crnode = crnode.prev
        for i in range(len(node_list)-1, -1, -1):
            print(node_list[i])

dll = DoublyLinkedList()
q = int(input())
for i in range(q):
    op = list(map(int, input().split(' ')))
    if op[0] == 0:
        dll.insert(op[1])
    elif op[0] == 1:
        dll.move(op[1])
    elif op[0] == 2:
        dll.erase()

dll.print_elements()
### BUGGY CODE ###

N = int(input())
a = input().split(" ")
b= []

flag = True
for i in range(N):

    if a[i] in b:
        flag = False
        break
    b.append(a[i])


if flag:
    print("YES")

else:
    print("NO")

    
    

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split(" ")))
b=a
b.sort()

flag = True
s =0
e =N-1
for i in range(N-1):
    if b[i] == b[i+1]:
        flag = False
        break
        



if flag:
    print("YES")

else:
    print("NO")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

n = int(input())
def num(n):
    if n == 1:
        return 1
    return n + num(n-1)
print(num(n-1))

### FIXED CODE ###

n = int(input())
print((n*(n-1))//2)
### BUGGY CODE ###

N,M=input().split(" ")
N=int(N)
M=int(M)
Alist=input().split(" ")
Alist = [float(A) for A in Alist]

for m in range(M):
    Alist.sort()
    Alist[-1]=Alist[-1]/2

Alist = [int(A) for A in Alist]
print(sum(Alist))

### FIXED CODE ###

from heapq import heappush,heappop
N,M=input().split(" ")
N=int(N)
M=int(M)
Alist=input().split(" ")
# Alist = [-float(A) for A in Alist]
hAqueue=[]
for A in Alist:
    heappush(hAqueue,-float(A))

for m in range(M):
    tmp=heappop(hAqueue)
    heappush(hAqueue,tmp/2)
Alist = [-int(A) for A in hAqueue]
print(sum(Alist))
### BUGGY CODE ###

from collections import defaultdict,deque
import copy 

N ,M ,K = [int(i) for i in input().split(' ')]
AB = defaultdict(deque)

arrive_size = [-1] * N

for _ in range(M):
    a, b = [int(i) for i in input().split(' ')]
    AB[a].append(b)
    AB[b].append(a)

CD = defaultdict(list)
for _ in range(K):
    c, d = [int(i) for i in input().split(' ')]
    CD[c].append(d)
    CD[d].append(c)

def DFS_size(s, Graph):
    stack = deque([s])
    size = 1
    arrive = [0] * N
    tree = set()
    while stack:
        v = stack[-1]
        arrive[v-1] = 1
        tree.add(v)
        if Graph[v]:
            w = Graph[v].popleft()
            if arrive[w-1] == 0:
                if not w in stack:
                    arrive[w-1] =1
                    stack.append(w)
        else:
            stack.pop()

    for i, a in enumerate(arrive):
        if a == 1:
            arrive_size[i] = size

    return tree

tree_all =[]
tree_size = [None] *N
for i in range(1,N+1):
    if arrive_size[i-1] == -1:
        Graph = copy.deepcopy(AB)
        tree = DFS_size(i,Graph)
        for t in tree:
            size = len(tree)
            for block in CD[t]:
                if block in tree:
                    size -= 1
            for friend in AB[t]:
                if friend in tree:
                    size -= 1
            tree_size[t-1] = size - 1

print(' '.join(map(str,tree_size)))


### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, M, K = map(int, input().split())

def dfs(v):
    size = 1
    for w in fr[v]:
        if ~roots[w]: continue
        roots[w] = roots[v]
        size += dfs(w)
    return size

fr = defaultdict(set)
for _ in range(M):
    a, b = [int(x) -1 for x in input().split()]
    fr[a].add(b)
    fr[b].add(a)
bl = defaultdict(set)
for _ in range(K):
    a, b = [int(x) - 1 for x in input().split()]
    bl[a].add(b)
    bl[b].add(a)

roots = [-1] * N
sizes = [-1] * N

for v in range(N):
    if ~roots[v]: continue
    roots[v] = v
    sizes[v] = dfs(v)

ans = []
for v in range(N):
    w = roots[v]
    res = sizes[w] - len(fr[v]) - sum(1 for u in bl[v] if roots[u] == w) -1
    ans.append(res)

print(*ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(int(input()) for i in  range(m))

p = 10**9+7
dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2])%p
    if i in a:
        dp[i] = 0
print(dp[n])



### FIXED CODE ###

n, m = map(int, input().split())
a = set(list(int(input()) for i in  range(m)))

p = 10**9+7
dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    dp[i] = (dp[i-1] + dp[i-2])%p
    if i in a:
        dp[i] = 0
print(dp[n])
### BUGGY CODE ###

def main():
  from builtins import input, int, map
  N = int(input())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort()
  B.sort()
  C.sort()

  ans = 0

  for i in range(N):
    if A[0] >= B[i]:
      continue
    if A[N-1] < B[i]:
      a = N
    else:
      left = 0
      right = N-1
      while right - left > 1:
        mid = (left + right) // 2
        if  B[i]> A[mid]:
          left = mid
        else:
          right = mid
      a = left + 1
    if C[N-1] <= B[i]:
      continue
    if C[0] > B[i]:
      c = N
    else:      
      left = 0
      right = N-1
      while right - left > 1:
        mid = (left + right) // 2
        if B[i]>= C[mid]:
          left = mid
        else:
          right = mid
      c = len(C[right:])
    ans += a*c
  print(ans)
main()

### FIXED CODE ###

import bisect as bi
def main():
  from builtins import input, int, map
  N = int(input())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort()
  C.sort()

  ans = 0

  for i in range(N):
    a = bi.bisect_left(A,B[i])
    c = N-bi.bisect_right(C,B[i])
    ans += a*c
  print(ans)
main()
### BUGGY CODE ###

import fractions

N, M = list(map(int, input().split()))
S = input()
T = input()

def lcm(a, b):
	return a * b // fractions.gcd (a, b)

ans = lcm(N, M)

i = 0
res = [0 for i in range(ans)]

for i in range(N):
    tmp_s = int(ans/N) * i
    res[tmp_s] = S[i]

for j in range(M):
    tmp_t = int(ans/M) * j
    if res[tmp_t] != 0:
        if T[j] != res[tmp_t]:
            ans = -1

print(ans)


### FIXED CODE ###

import fractions


def lcm(x, y):
    return int((x * y) // fractions.gcd(x, y))

n, m = [int(i) for i in input().split()]
s = input()
t = input()

span = fractions.gcd(n, m)
for i in range(span):
    if s[int(n/span)*i] != t[int(m/span)*i]:
        print("-1")
        exit()
print(lcm(n, m))
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
INF = 10 ** 9
dp = [INF]*N
dp[0] = 0
for i in range(N):
    for j in range(K):
        target=i+j+1
        if target < N:
            tmp = dp[i] + abs(H[i]-H[target])
            dp[target] = min(dp[target], tmp)
print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
INF = 10 ** 9
dp = [INF]*N
dp[0] = 0
for i in range(N):
    for j in range(K):
        target=i+j+1
        if target < N:
            tmp = dp[i] + abs(H[i]-H[target])
            dp[target] = min(dp[target], tmp)
print(dp[N-1])
### BUGGY CODE ###

K = int(input())

now = 0
count = 0
while True:
    now = now * 10 + 7
    count += 1
    if now % K == 0:
        print(count)
        exit()


### FIXED CODE ###

K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
now = 0
count = 0
while True:
    now = (now * 10 + 7) % K
    count += 1
    if now % K == 0:
        print(count)
        exit()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

for i in range(n):
    temporary_list = list(numbers)
    temporary_list.pop(i)
    print(max(temporary_list))

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
n = int(input())
data = [int(input()) for k in range(n)]
m1,m2 = sorted(data, reverse=1)[:2]
b = [m2 if x==m1 else m1 for x in data]
print('\n'.join(map(str,b)))
### BUGGY CODE ###

x,y,z,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

ab=[]
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])

if len(ab)>k:
    ab.sort(reverse=True)
    ab=ab[:k]
else:
    ab.sort(reverse=True)

ans=[]
for i in range(len(ab)):
    for j in range(z):
        ans.append(ab[i]+c[j])
ans.sort(reverse=True)

for i in range(k):
    print(ans[i])



### FIXED CODE ###

x,y,z,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

ab=[]
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])

if len(ab)>k:
    ab.sort(reverse=True)
    ab=ab[:k]
else:
    ab.sort(reverse=True)

ans=[]
for i in range(len(ab)):
    for j in range(z):
        ans.append(ab[i]+c[j])
ans.sort(reverse=True)

for i in range(k):
    print(ans[i])
### BUGGY CODE ###

import sys

def main():
  n, k, *h = map(int, sys.stdin.read().split())
  dp = [float("inf")] * n
  dp[0] = 0
  for i in range(1, n):
    if i < k:
      dp[i] = min([ dp[j]+abs(h[j]-h[i]) for j in range(i) ])
    else:
      dp[i] = min( [ dp[i-j-1]+abs(h[i-j-1]-h[i]) for j in range(k) ] )
  print(dp[n-1])
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf")] * n
dp[0] = 0
for i in range(1, n):
  if i < k:
    dp[i] = min([ dp[j]+abs(h[j]-h[i]) for j in range(i) ])
  else:
    dp[i] = min( [ dp[i-j-1]+abs(h[i-j-1]-h[i]) for j in range(k) ] )
print(dp[n-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(200000)
 
n, k = map(int, input().split())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  m = min([dp(p+i)+abs(h[p]-h[p+i]) for i in range(1, min(n-p, k+1))])
  d[p] = m
  return m

print(dp(0))

### FIXED CODE ###

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

dp = [0] * n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
  a = [0] * min(i,k)
  for j in range(1, min(i,k)+1): 
    a[j-1] = dp[i-j]+abs(h[i]-h[i-j])
  dp[i] = min(a)

print(dp[-1])
### BUGGY CODE ###

a=list(map(int,input().split()))
b=list(map(lambda b:abs(int(b)-a[1]),input().split()))
def ucl(a,b):
  if a%b==0:
    return b
  else:
    return ucl(b,a%b)
while len(b)>1:
  b+=[ucl(b[0],b[1])]
  del b[0]
  del b[0]
print(b[0])  

### FIXED CODE ###

a=list(map(int,input().split()))
x=[]
for i in input().split():
  x.append(abs(int(i)-a[1]))
def ucl(a,b):
  if a%b==0:
    return b
  else:
    return ucl(b,a%b)
while len(x) > 1:
  x2 = []
  mn_x = min(x)
  for n in range(len(x)):
    mod = x[n] % mn_x
    if mod != 0:
      x2.append(mod)
  x2.append(mn_x)
  x = x2
print(x[0])
### BUGGY CODE ###

k = int(input())
s = input()

n = len(s)
mod = 10**9+7


def framod(n, mod, a=1):
    for i in range(1, n+1):
        a = a * i % mod
    return a


def power(n, r, mod):
    if r == 0:
        return 1
    if r % 2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r % 2 == 1:
        return n * power(n, r-1, mod) % mod


def comb(n, k, mod):
    a = framod(n, mod)
    b = framod(k, mod)
    c = framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


com = [1]*k
# or i in range(k+1):
#comb[i+1] = comb

a25 = [1]*(k+1)
for i in range(k):
    a25[i+1] = a25[i]*25 % mod
a26 = [1]*(k+1)
for i in range(k):
    a26[i+1] = a26[i]*26 % mod
num = 0
for i in range(0, k+1):
    num = (num+comb(i+n-1, n-1, mod)*a25[i] % mod * a26[k-i]) % mod
print(num)


### FIXED CODE ###

k = int(input())
s = input()

n = len(s)
mod = 10**9+7


def framod(n, mod, a=1):
    for i in range(1, n+1):
        a = a * i % mod
    return a


def power(n, r, mod):
    if r == 0:
        return 1
    if r % 2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r % 2 == 1:
        return n * power(n, r-1, mod) % mod


def comb(n, k, mod):
    a = framod(n, mod)
    b = framod(k, mod)
    c = framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod


com = [1]*(k+1)
for i in range(k):
    com[i+1] = com[i]*(n+i)*pow(i+1, mod-2, mod) % mod

a25 = [1]*(k+1)
for i in range(k):
    a25[i+1] = a25[i]*25 % mod
a26 = [1]*(k+1)
for i in range(k):
    a26[i+1] = a26[i]*26 % mod
num = 0
for i in range(0, k+1):
    num = (num+com[i]*a25[i] % mod * a26[k-i]) % mod
print(num)
### BUGGY CODE ###

N, M = list(map(int, input().split()))
can = []
for i in range(1, M+1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		else:
			break

print(max(can))


### FIXED CODE ###

import numpy as np
N, M = list(map(int, input().split()))
can = []
for i in range(1, int(np.sqrt(M)) + 1):
	if M % i == 0:
		if N <= M // i:
			can.append(i)
		if N <= i:
			can.append(M // i)

if N == 1:
	print(M)
else:
	print(max(can))
### BUGGY CODE ###

n = int(input())
v = list(map(int,input().split()))
b = []
c = []

for i, vv in enumerate(v):
    if i%2 == 0:
        b.append(vv)
    else:
        c.append(vv)

b_set = []
c_set = []

for bb in set(b):
    b_set.append((b.count(bb), bb))
for cc in set(c):
    c_set.append((c.count(cc), cc))

b_set.sort(reverse=True)
b_set.append((0,0))
c_set.sort(reverse=True)
c_set.append((0,0))

if b_set[0][1] != c_set[0][1]:
    ans = n - b_set[0][0] - c_set[0][0]
else:
    try1 = n - b_set[1][0] - c_set[0][0]
    try2 = n - b_set[0][0] - c_set[1][0]
    ans = min(try1,try2)

print(ans)

### FIXED CODE ###

n = int(input())
v = list(map(int,input().split()))
b = []
c = []

for i, vv in enumerate(v):
    if i%2 == 0:
        b.append(vv)
    else:
        c.append(vv)

b_set = {}
c_set = {}

for bb in b:
    if not bb in b_set.keys():
        b_set[bb] = 1
    else:
        b_set[bb] += 1

for cc in c:
    if not cc in c_set.keys():
        c_set[cc] = 1
    else:
        c_set[cc] += 1

b_sorted = []
c_sorted = []

for key, value in b_set.items():
    b_sorted.append([value,key])
for key, value in c_set.items():
    c_sorted.append([value,key])

b_sorted = sorted(b_sorted, reverse=True)
b_sorted += [[0,0]]
c_sorted = sorted(c_sorted, reverse=True)
c_sorted += [[0,0]]


if b_sorted[0][1] != c_sorted[0][1]:
    ans = n - b_sorted[0][0] - c_sorted[0][0]
else:
    try1 = n - b_sorted[1][0] - c_sorted[0][0]
    try2 = n - b_sorted[0][0] - c_sorted[1][0]
    ans = min(try1,try2)

print(ans)
### BUGGY CODE ###

import numpy as np
a = list(map(int,input().split()))
N = a[0]
K = a[1]
b = list(map(int,input().split()))
li = list(set(b))
c = np.array(b)
d = np.array([])
h = len(li) -K
Num = 0
if K >= len(li):
  print(0)
  exit()
for i in li :
  ind = c[np.where(c== i)]
  d = np.append(d,ind.shape)
d = np.sort(d)
print(int(np.sum(d[:h])))

### FIXED CODE ###

import numpy as np
from collections import Counter
import collections
a = list(map(int,input().split()))
N = a[0]
K = a[1]
d = np.array([])
b = list(map(int,input().split()))
li = list(set(b))
c = np.array(b)
l = Counter(b)
h = len(li) -K
Num = 0
if K >= len(li):
  print(0)
  exit()
d = np.append(d,list(l.values()))
d = np.sort(d)
for i in range(h):
  Num += d[i]
print(int(Num))
### BUGGY CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
L = []
for i in range(N-1):
  for j in range(i+1, N):
    L.append(min(j-i, abs(i-X)+1+abs(j-Y)))
for i in range(1, N):
  print(L.count(i))

### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
out = [0] * N
L = []
for i in range(N-1):
  for j in range(i+1, N):
    out[min(j-i, abs(i-X)+1+abs(j-Y))] += 1
for i in range(1, N):
  print(out[i])
### BUGGY CODE ###

# coding: utf-8 
# Your code here! 
H,W=map(int,input().split()) 
S=[] 

ku=0
for _ in range(H): 
    S.append(list(input()))
    ku+=S[-1].count(".")


def bfs(h,w,num):
    if h==H-1 and w==W-1:
        print(ku-num-1)
        exit() 
    else:
        S[h][w]="#"

    if h!=0: 
        if S[h-1][w]!="#": 
            temp.append([h-1,w]) 

    if w!=0: 
        if S[h][w-1]!="#": 
            temp.append([h,w-1]) 

    if h!=H-1: 
        if S[h+1][w]!="#": 
            temp.append([h+1,w]) 

    if w!=W-1: 
        if S[h][w+1]!="#": 
            temp.append([h,w+1]) 
        
q=[[0,0]] 
count=-1
while True: 
    count+=1
    temp=[]
    while q:
        l=q.pop(0)
        bfs(l[0],l[1],count)
        
    q=temp[:]
    if len(q)==0:
        print(-1)
        exit()




    

### FIXED CODE ###

# coding: utf-8 
# Your code here! 
H,W=map(int,input().split()) 
S=[] 

ku=0
for _ in range(H): 
    S.append(list(input()))
    ku+=S[-1].count(".")


def bfs(h,w,num):
    if h==H-1 and w==W-1:
        print(ku-num-1)
        exit() 
    else:
        pass

    if h!=0: 
        if S[h-1][w]!="#": 
            temp.append([h-1,w])
            S[h-1][w]="#"

    if w!=0: 
        if S[h][w-1]!="#": 
            temp.append([h,w-1]) 
            S[h][w-1]="#"

    if h!=H-1: 
        if S[h+1][w]!="#": 
            temp.append([h+1,w]) 
            S[h+1][w]="#"

    if w!=W-1: 
        if S[h][w+1]!="#": 
            temp.append([h,w+1]) 
            S[h][w+1]="#"
        
q=[[0,0]] 
count=-1
while True: 
    count+=1
    #print(q)
    temp=[]
    while q:
        l=q.pop(0)
        bfs(l[0],l[1],count)
        
    q=temp[:]
    if len(q)==0:
        print(-1)
        exit()
### BUGGY CODE ###

s = input().rstrip()

result = [0] * len(s)
for i in range(len(s)):
    if s[i] == 'R':
        for j in range(1, len(s)):
            if s[i+j] == 'L':
                break
        if j % 2 == 0:
            result[i+j] += 1
        else:
            result[i+j-1] += 1
    else:
        for j in range(1, len(s)):
            if s[i-j] == 'R':
                break
        if j % 2 == 0:
            result[i-j] += 1
        else:
            result[i-j+1] += 1
print(*result)

### FIXED CODE ###

s = input().rstrip()

table = [0] * len(s)

start = 0
pre = 'R'
for i in range(1, len(s)):
    if pre != s[i]:
        if pre == 'R':
            for j in range(start, i):
                if (i - j) % 2 == 0:
                    table[i] += 1
                else:
                    table[i-1] += 1
        else:
            for j in range(start, i):
                if (i - j) % 2 == 0:
                    table[start-1] += 1
                else:
                    table[start] += 1

        pre = s[i]
        start = i

for j in range(start, len(s)):
    if (len(s) - j) % 2 == 0:
        table[start - 1] += 1
    else:
        table[start] += 1

print(*table)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

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

ps = [0] * (n + 1)
for _ in range(q):
    p, v = map(int, input().split())
    ps[p] += v

visited = [False] * (n + 1)
visited[0] = True
visited[1] = True
while not all(visited):
    for a in range(1, n + 1):
        if not visited[a]:
            continue
        for b in es[a]:
            if not visited[b]:
                ps[b] += ps[a]
            visited[b] = True
print(*ps[1:])

### FIXED CODE ###

import collections
import sys

input = sys.stdin.readline

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

ps = [0] * (n + 1)
for _ in range(q):
    p, v = map(int, input().split())
    ps[p] += v

remaining = collections.deque([[0, 1]])
while len(remaining) > 0:
    a, b = remaining.popleft()
    ps[b] += ps[a]
    for c in es[b]:
        if c != a:
            remaining.append([b, c])
print(*ps[1:])
### BUGGY CODE ###

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

aa = set(a)
for i in range(1, n+1):
    if i in aa:
        print(a.count(i))
    else:
        print(0)

### FIXED CODE ###

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

ans = [0]*n
for i in a:
    ans[i-1] += 1
for i in range(n):
    print(ans[i])