Harryxun/stf_run huggingface dataset:
#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())
dp = [[0]*20 for _ in range(20)]
dq = [[0]*20 for _ in range(20)]

for i in range(n):
    s = input()
    x = s.find('.')
    if x == -1:
        s = s + '0'*9
    else:
        s = s.replace('.','') + '0'*(10-(len(s)-x))
    s = int(s)
    d2 = 0
    d5 = 0
    for _ in range(20):
        if s%2 == 0:
            s = s//2
            d2 += 1
        else:
            break
    for _ in range(20):
        if s%5 == 0:
            s = s//5
            d5 += 1
        else:
            break
    dp[d2][d5] += 1
    dq[d2][d5] += 1

for i in range(19,-1,-1):
    for j in range(19,0,-1):
        dp[i][j-1]+=dp[i][j]
for j in range(19,-1,-1):
    for i in range(19,0,-1):
        dp[i-1][j]+=dp[i][j]
ret = 0
for i in range(18):
    for j in range(18):
        ret += dq[i][j] * dp[18-i][18-j]
ret -= dp[9][9]
print(ret//2)


### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())
dp = [[0]*19 for _ in range(19)]
dq = [[0]*19 for _ in range(19)]

for i in range(n):
    s = input()
    x = s.find('.')
    if x == -1:
        s = s + '0'*9
    else:
        s = s.replace('.','') + '0'*(10-(len(s)-x))
    s = int(s)
    d2 = 0
    d5 = 0
    for _ in range(18):
        if s%2 != 0:
            break
        s = s//2
        d2 += 1
    for _ in range(18):
        if s%5 != 0:
            break
        s = s//5
        d5 += 1
    dp[d2][d5] += 1
    dq[d2][d5] += 1

for i in range(18,-1,-1):
    for j in range(18,0,-1):
        dp[i][j-1]+=dp[i][j]
for j in range(18,-1,-1):
    for i in range(18,0,-1):
        dp[i-1][j]+=dp[i][j]

ret = 0
for i in range(19):
    for j in range(19):
        if dq[i][j] == 0:
            continue
        ret += dq[i][j] * dp[18-i][18-j]
ret -= dp[9][9]
print(ret//2)
a = int(input())
a >= 1
b = int(input())
b <= 10000

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')

### FIXED CODE ###

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

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')
'import sys'
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for i in range(n):
    s,num=input().split()
    c[s][int(num)-1]=1
for i in["S","H","C","D"]:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)



### FIXED CODE ###

# -*- coding: utf-8 -*-
'import sys'
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for i in range(n):
    s,num=input().split()
    c[s][int(num)-1]=1
for i in["S","H","C","D"]:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)
import math
A, B, H, M =map(int, input().split())
Hs = H/ 12 + 6*M
Ms = H/12 + M/2
shita = Hs-Ms
shita = abs(shita)
if  shita >= 180:
    shita = 180 - shita
shita = math.radians(shita)
C = A*A + B*B - 2*A*B*math.cos(shtia)
print (C ** 0.5)

### FIXED CODE ###

import math
A, B, H, M =map(int, input().split())
Hs = H*30 + M*0.5
Ms = 6*M
shita = Hs-Ms
shita = abs(shita)
if  shita >= 180:
    shita = 360 - shita
shita = math.radians(shita)
C = A*A + B*B - 2*A*B*(math.cos(shita))
print (math.sqrt(C))
S = int(put())
if S == "ABC"
	print("ARC")
else:
  	print("ABC")

### FIXED CODE ###

S = input()
if S == "ABC":
	print("ARC")
else:
  	print("ABC")
import heapq
INF = 10 ** 16


def dijkstra(n, town, k, start):
    d = []
    queue = []
    for i in range(n):
        d.append(INF)
    d[start] = 0
    heapq.heappush(queue, (0, start))
    # 都市kに行く時の円またはスヌークのの最小値
    while len(queue) != 0:
        distance, v = queue.pop()
        if d[v] < distance:
            continue
        for u in range(len(town[v])):
            if d[town[v][u][0]] > d[v] + town[v][u][k]:
                d[town[v][u][0]] = d[v] + town[v][u][k]
                heapq.heappush(queue, (d[town[v][u][0]], town[v][u][0]))

    return d


def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    money = 10 ** 15
    town = []

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

    a = dijkstra(n, town, 1, s)
    b = dijkstra(n, town, 2, t)

    total = []
    for i in range(n):
        heapq.heappush(total, (a[i] + b[i], i + 1))
    mon, year = heapq.heappop(total)
    for i in range(n):
        while year <= i:
            mon, year = heapq.heappop(total)
        print(money - mon)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from heapq import heapify, heappop, heappush


def dijkstra(n, train, start):
    d = []
    queue = []
    INF = 10 ** 16
    for i in range(n):
        d.append(INF)
    d[start] = 0
    heapify(queue)
    heappush(queue, (0, start))
    # 都市kに行く時の円またはスヌークのの最小値
    while len(queue) != 0:
        distance, v = heappop(queue)
        if d[v] < distance:
            continue
        for u in range(len(train[v])):
            if d[train[v][u][0]] > d[v] + train[v][u][1]:
                d[train[v][u][0]] = d[v] + train[v][u][1]
                heappush(queue, (d[train[v][u][0]], train[v][u][0]))
    return d


def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    money = 10 ** 15
    train_en = []
    train_snuuk = []

    for i in range(n):
        train_en.append([])
        train_snuuk.append([])
    for i in range(m):
        fro, to, a, b = map(int, input().split())
        fro -= 1
        to -= 1
        train_en[fro].append((to, a))
        train_en[to].append((fro, a))
        train_snuuk[fro].append((to, b))
        train_snuuk[to].append((fro, b))

    a = dijkstra(n, train_en, s)
    b = dijkstra(n, train_snuuk, t)

    cost_sum = []
    for i in range(n):
        cost_sum.append((a[i] + b[i], i + 1))
    heapify(cost_sum)
    m, y = heappop(cost_sum)
    for i in range(n):
        while y <= i:
            m, y = heappop(cost_sum)
        print(money - m)


if __name__ == '__main__':
    main()
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
for i in range(n):
    b.append(b[-1]+a[i])
max=0
for j in range(k,len(b)+1):
    if max<b[j]-b[j-k]:
        max=b[j]-b[j-k]
print((max+k)/2)



### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
for i in range(n):
    b.append(b[-1]+a[i])
max=0
for j in range(k,len(b)):
    if max<b[j]-b[j-k]:
        max=b[j]-b[j-k]
print((max+k)/2)
from collections import*
n=int(input())
d=defaultdict(list)

q=[]
for i in range(n-1):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
    q.append(tuple(sorted([a,b])))
    
#print(d)
m=max(map(len,d.values()))
print(m)

dcolars={}

def BFS(d,point,c):
    colar=0
    for i in d[point]:
        colar+=1
        if tuple(sorted([point,i])) not in dcolars:
            if c==colar:
                colar+=1
            dcolars[tuple(sorted([point,i]))]=colar
            dcolars[tuple(sorted([point,i])[::-1])]=colar
            BFS(d,i,colar)

    return dcolars

ans=BFS(d,1,0)

for i in q:
    print(ans[i])

### FIXED CODE ###

from collections import*
import sys
sys.setrecursionlimit(10**8)
input=sys.stdin.readline

n=int(input())
d={}

q=[]
for i in range(n-1):
    a,b=map(int,input().split())
    if a not in d:
        d[a]=[]
    if b not in d:
        d[b]=[]
    d[b].append(a)
    d[a].append(b)        
    q.append(tuple(sorted([a,b])))

m=max(map(len,d.values()))
print(m)

dcolars={}

def BFS(d,point,c):
    for i in d[point]:
        if tuple(sorted([point,i])) not in dcolars:
            c+=1
            if c==m+1:
                c=1
            dcolars[tuple(sorted([point,i]))]=c
            BFS(d,i,c)
    return dcolars

ans=BFS(d,1,0)

for i in q:
    print(ans[i])
N, A, B = map(int,input().split())

if NA > B:
    print(B)
elif NA < B:
    print(AN)
else:
    print(AN)

### FIXED CODE ###

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

if N*A>=B:
    print(B)
elif N*A<=B:
    print(N*A)
n = int(input())
tmp = 1
lipos = [1]
while tmp<10**9:
  tmp *= 4
  lipos.append(lipos[-1]+tmp)
#print(lipos)
tmp = -2
lineg = [-2]
while tmp > - 10**9:
  tmp *= 4
  lineg.append(lineg[-1]+tmp)
#print(lineg)
if n == 0:
  print("0")
elif n == 1:
  print("1")
elif n == -1:
  print("10")
elif n > 0:
  flag = True
  i = 0
  while flag:
    if lipos[i] < n <= lipos[i+1]:
      k = i+1
      flag = False
    i += 1
  diff = lipos[k]-n
  print(bin(lipos[k]^diff)[2:])
else:
  flag = True
  i = 0
  if lineg[i] > n >= lineg[i+1]:
    k = i+1
    flag = False
  i += 1
  diff = n-lineg[k]
  print(bin((-lineg[k])^diff)[2:])

### FIXED CODE ###

n = int(input())
tmp = 1
lipos = [1]
while tmp<10**9:
  tmp *= 4
  lipos.append(lipos[-1]+tmp)
#print(lipos)
tmp = -2
lineg = [-2]
while tmp > - 10**9:
  tmp *= 4
  lineg.append(lineg[-1]+tmp)
#print(lineg)
if n == 0:
  print("0")
elif n == 1:
  print("1")
elif n == -1:
  print("10")
elif n > 0:
  flag = True
  i = 0
  while flag:
    if lipos[i] < n <= lipos[i+1]:
      k = i+1
      flag = False
    i += 1
  diff = lipos[k]-n
  print(bin(lipos[k]^diff)[2:])
else:
  flag = True
  i = 0
  while flag:
    if lineg[i] > n > lineg[i+1]:
      k = i+1
      flag = False
    i += 1
  diff = n-lineg[k]
  print(bin((-lineg[k])^diff)[2:])
import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 

def update( k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
    
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x-0.4,True,x,i), (t-x-0.5,False,x,i)]
    for _ in range(Q):
        xs.append((int(input()),2))
    xs.sort(key=lambda x:x[0])
    for x in xs:
        if x[1]==2:
            print(segl[0] if segl[0]!= mx else -1)
            continue
        update(x[3], x[2] if x[1] else mx)


### FIXED CODE ###

a, b = map(int, input().split())
print((a*3 + b)//2)
print('A'+'RB'[input()[:2]<’12’]+'C')

### FIXED CODE ###

print('A'+'RB'[int(input())<1200]+'C')
A1 =int(input())
A2 =int(input())
A3 =int(input())

if A1+A2+A3 > 21:
    print("lose")
else:
    print("win")

### FIXED CODE ###

A0,A1,A2 = (int(x) for x in input().split())

if A0+A1+A2 > 21:
    print("bust")
else:
    print("win")
#BBBBBBBBBBB
 
import sys
import math
import itertools
import collections
import heapq
import numpy as np
 
rl = sys.stdin.readline
 
t = rl()
li = []
for i in range(len(t)):
    if t[i] == '?':
        li.append('D')
    else:
        li.append(t[i])
print(''.join(li))

### FIXED CODE ###

#BBBBBBBBBBB

import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

t = rl()
li = []
for i in range(len(t)):
    if t[i] == '?':
        li.append('D')
    else:
        li.append(t[i])
print(''.join(li))
import math
def lcm(a,b):
    return (a*b)/math.gcd(a,b)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

ans = T[0]
for i in range(1,N):
    ans = lcm(int(ans),int(T[i]))
print(int(ans))

### FIXED CODE ###

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a


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


N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

t = T[0]
for i in range(N - 1):
    t = lcm(t,T[i+1])
print(t)
import math
S = str(input())
len = len(S)

count = 0
for i in range(len):
  while count > len/2 or i == len:
	if S[i] != S[len-i]:
    	count += count
if count < len/2:
  print(count)
else:
  print(math.floor(len/2))


### FIXED CODE ###

import math
S = str(input())
length = len(S)
 
count = 0
for i in range(math.floor(length/2)):
    if S[i] != S[length-i-1]:
        count += 1
        
if count < length/2:
    print(count)
else:
    print(math.floor(length/2))
# -*- coding: utf-8 -*-
"""
Created on Wed May  2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr

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

for i in m:
    yesorno = False
    b = []
    for j in a:
        if j <= i:
            b.append(j)
    #print(b)
    lb = len(b)
    if lb >= 1:
        for r in range(1, 2**lb):
            bin_str = format(r, 'b')
            sumb = sum([b[k]*int(bin_str[k]) for k in range(lb)])    #print(i,comb)
            if sumb == i:
                yesorno = True
                break
            if yesorno:
                break
    if yesorno:
        print('yes')
    else:
        print('no')


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed May  2 21:28:06 2018
ALDS1_5a_r1  
@author: maezawa
"""
import itertools as itr

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

sum_array = []
for r in range(1,n+1):
    for comb in itr.combinations(a, r):
        sum_array.append(sum(comb))
sum_array.sort()

for i in m:
    left = 0
    right = len(sum_array)
    yesorno = 'no'
    while(left < right):
        #print(left, right)
        mid = (left+right)//2
        if sum_array[mid] == i:
            yesorno = 'yes'
            break
        elif sum_array[mid] > i:
            right = mid
        else:
            left = mid+1
            
    print(yesorno)
def gcd(a, b):
    return b if a == 0 else gcd(b%a, a)
num = [int(x) for x in input().split(" ")]
print(int(num[0]*num[1]/gcd(num[0], num[1])))


### FIXED CODE ###

def gcd(a, b):
    return b if a == 0 else gcd(b%a, a)
num = [int(x) for x in input().split(" ")]
print(int(num[0]*num[1]/gcd(num[0], num[1])))
s=ord(input())
n=int(input())
ans=s-65+n
if ans>=26:
  ans=ans%26
print(chr(ans+65))


### FIXED CODE ###

N = int(input())
S = input()

ans = ''
for c in S:
    i = ord(c) - ord('A')
    i = (i+N)%26
    ans += chr(i + ord('A'))
print(ans)
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]='s':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)

### FIXED CODE ###

s=input()
c=0
tmp=0
for i in range(3):
    if s[i]=='R':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)
import sys
H, W, M = map(int, input().split())
hList = {i+1: 0 for i in range(H)}
wList = {i+1: 0 for i in range(W)}
pList = set()
#print(hList, wList, pList)
for _ in range(M):
  h, w = list(map(int, input().split()))
  #print(h, w)
  hList[h] += 1
  wList[w] += 1
  pList.add((h, w))
#print(hList, wList, pList)

maxHCount = max(hList.values())
maxHList = [h for h, count in hList.items() if count==maxHCount]


maxWCount = max(wList.values())
maxWList = [w for w, count in wList.items() if count==maxWCount]

#counterList = []
#for maxH in maxHList:
#  for maxW in maxWList:
#    counterList.append(hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0))
#print(max(counterList))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))

for maxH in maxHList:
  for maxW in maxWList:
    if (maxH, maxW) in pList:
      print(maxHCount + maxWList - 1)
      sys.exit(0)

print(maxHCount + maxWList)


### FIXED CODE ###

import sys
H, W, M = map(int, input().split())
hList = {i+1: 0 for i in range(H)}
wList = {i+1: 0 for i in range(W)}
pList = set()
#print(hList, wList, pList)
for _ in range(M):
  h, w = list(map(int, input().split()))
  #print(h, w)
  hList[h] += 1
  wList[w] += 1
  pList.add((h, w))
#print(hList, wList, pList)

maxHCount = max(hList.values())
maxHList = [h for h, count in hList.items() if count==maxHCount]


maxWCount = max(wList.values())
maxWList = [w for w, count in wList.items() if count==maxWCount]

#counterList = []
#for maxH in maxHList:
#  for maxW in maxWList:
#    counterList.append(hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0))
#print(max(counterList))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))

#if M < len(maxHList)*len(maxWList):
#	print(maxHCount + maxWCount)
#	sys.exit(0)

for maxH in maxHList:
  for maxW in maxWList:
    if (maxH, maxW) not in pList:
      print(maxHCount + maxWCount)
      sys.exit(0)

print(maxHCount + maxWCount - 1)
n = str(input())
for i, s in enumerate(n):
  if s == "1":
    n[i] = "9"
  elif s == "9":
    n[i] = "1"

print(int(n))

### FIXED CODE ###

n = str(input()).replace("1","q").replace("9","1").replace("q","9")
print(n)
s = input()
rev_s = s[::-1]
count = 0
if len(set(s)) == 1:
    print(0)
    exit()
left = 0
right = len(s) - 1

ans = 0
while True:
    if (s[left] == 'x' and s[right] == 'x') or s[left] == s[right]:
        left += 1
        right -= 1
    if s[left] == 'x' and s[right] != 'x':
        ans += 1
        left += 1
    elif s[left] != 'x' and s[right] == 'x':
        ans += 1
        right -= 1
    elif s[left] != 'x' and s[right] != 'x' and s[left] != s[right]:
        print(-1)
        exit()
    if left == right:
        break
print(ans)

### FIXED CODE ###

s = input()
count = 0
if len(set(s)) == 1:
    print(0)
    exit()
left = 0
right = len(s) - 1

ans = 0
while True:
    if (s[left] == 'x' and s[right] == 'x') or s[left] == s[right]:
        left += 1
        right -= 1
    elif s[left] == 'x' and s[right] != 'x':
        ans += 1
        left += 1
    elif s[left] != 'x' and s[right] == 'x':
        ans += 1
        right -= 1
    elif s[left] != 'x' and s[right] != 'x' and s[left] != s[right]:
        print(-1)
        exit()
    if right <= left:
        break
print(ans)
if a % 2 == 0 or b % 2 == 0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

a, b = map(int, input().split())
if a * b % 2 == 0:
  print('Even')
else:
  print('Odd')
import math
import bisect
N, M = map(int, input().split())
rootM = math.sqrt(M)

factors = set()
for i in range(1, math.ceil(rootM)):
  if M % i == 0:
    factors.add(i)
    factors.add(M // i)
factarr = sorted(list(factors))
print(M // factarr[bisect.bisect_left(factarr, N)])

### FIXED CODE ###

import math
import bisect
N, M = map(int, input().split())
rootM = math.sqrt(M)

factors = set()
for i in range(1, math.ceil(rootM)+1):
  if M % i == 0:
    factors.add(i)
    factors.add(M // i)
factarr = sorted(list(factors))
print(M // factarr[bisect.bisect_left(factarr, N)])
n=int(input())
a='Xabcdefghijklmnopqrstuvwxyz'
a=list(a)
j=11
ans=''
while True:
    while n<26**j:
        j-=1
    temp=a[n//26**j]
    ans+=temp
    n%=26**j
    j-=1
    if j==-1:
        break
print(ans)


### FIXED CODE ###

n=int(input())
n-=1
a='abcdefghijklmnopqrstuvwxyz'
a=list(a)
ans=''
for i in range(1,20):
    if n<26**i:
        for j in range(i):
            ans+=a[n%26]
            n//=26
        break
    else:
        n-=26**i
print(ans[::-1])
import numpy as np
N, M = map(int, input().split())
A = np.array([int(input()) for _ in range(M)], dtype = int)
l_a = len(A)

MOD= 1000000007
dp = np.zeros(N, dtype = int)
dp[A - 1] = - 1
if dp[0] == -1 and dp[1] == -1:
    pass
elif dp[0] == -1:
    dp[1] = 1
elif dp[1] == -1:
    dp[0] = 1
else:
    dp[0] = 1; dp[1] = 2;


if N >= 3:
    for n in range(2, N):
        if dp[n] != -1:
            dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
import numpy as np
N, M = map(int, input().split())

MOD = 1000000007
dp = np.zeros(N, dtype = int)
if M != 0:
    A = np.array([int(input()) for _ in range(M)], dtype = int)
    dp[A - 1] = -1


if dp[0] == -1 and dp[1] == -1:
    pass
else:
    if dp[0] == -1:
        dp[1] = 1
    elif N >= 2 and dp[1] == -1:
        dp[0] = 1
    elif N >= 2:
        dp[0] = 1
        dp[1] = 2
    else:
        dp[0] = 1


if N >= 3:
    for n in range(2, N):
        if dp[n] != -1:
            dp[n] = (max(dp[n-1], 0) + max(dp[n-2], 0)) % MOD

print (dp[-1])
n = int(input())
a = list(map(int,input().split()))
q = int(input())
u = []
for i in range(q):
    u.append(tuple(map(int,input().split())))

from collections import Counter
z = Counter(a)

sum = sum(a)
for i in range(q):
    try:
        rev = z.pop(u[i][0])
        sum+=(u[i][1]-u[i][0])*rev
        print(sum)
    except KeyError:
        print(sum)
    if u[i][1] in z:
        z[u[i][1]]+=rev
    else:
        z[u[i][1]]=rev

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
q = int(input())
u = []
for i in range(q):
    u.append(tuple(map(int,input().split())))

from collections import Counter
z = Counter(a)

sum = sum(a)
for i in range(q):
    try:
        rev = z.pop(u[i][0])
        sum+=(u[i][1]-u[i][0])*rev
        print(sum)
        if u[i][1] in z:
            z[u[i][1]]+=rev
        else:
            z[u[i][1]]=rev
    except KeyError:
        print(sum)
n=int(input())
a=[int(x) for x in input().split()]
import math
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    ans=numbers[0]
    for i in numbers:
        ans=math.gcd(ans,i)
    return ans
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

### FIXED CODE ###

n=int(input())
a=[int(x) for x in input().split()]
print(sum([(ai-1)%ai for ai in a]))
n,k = map(int,input().split())
s=[]
for i in range(k):
  s= int(input())
  l=list(map(int,input().split()))
  s=s+l
r=set(s)
print(n-len(r))
  

### FIXED CODE ###

n,k = map(int,input().split())
e=[]
for i in range(k):
  s= int(input())
  l=list(map(int,input().split()))
  e=e+l
r=set(e)
print(n-len(r))
from functools import *
from collections import *
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
 
M = 10**9+7
N = int(input())

@lru_cache(maxsize=None)
def mod_inv(x):
  if x == 1:
    return 1
  return M // x * -mod_inv(M%x) % M

weght = [0]*(N+1)
size = [0]*(N+1)
def calc_subtree(v):
  W = 1
  S = 1
  for child in Edge[v]:
    Edge[child].remove(v)
    w, s = calc_subtree(child)
    W = W * w % M
    S += s
  weight[v] = W * S % M
  size[v] = S
  return weight[v], size[v]

ans = [0]*(N+1)
def set_ans(v, a):
  ans[v] = a
  for child in Edge[v]:
    n = calc_subtree(child)[1]
    set_ans(child, ans[v] * n * mod_inv(N-n) % M)

Edge = defaultdict(set)
fact = N
for i in range(1, N):
  fact = fact * i % M
  a, b = map(int, input().split())
  Edge[a].add(b)
  Edge[b].add(a)

set_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)
for i in range(1, N+1):
  print(ans[i])



### FIXED CODE ###

from functools import *
from collections import *
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
 
M = 10**9+7

@lru_cache(maxsize=None)
def mod_inv(a):
  b, x, y = M, 1, 0
  while a != 1:
    (d, a), b = divmod(b, a), a
    x, y = y-d*x, x
  return x%M

@lru_cache(maxsize=None)
def calc_subtree(v):
  ret = 1
  size = 1
  for child in Edge[v]:
    Edge[child].remove(v)
    r, s = calc_subtree(child)
    ret = ret * r % M
    size += s
      
  ret = ret * size % M
  return ret, size

ans = {}
def set_ans(v, a):
  ans[v] = a
  for child in Edge[v]:
    n = calc_subtree(child)[1]
    set_ans(child, ans[v] * n * mod_inv(N-n) % M)

N = int(input())
Edge = defaultdict(set)
fact = N
for i in range(1, N):
  fact = fact * i % M
  a, b = map(int, input().split())
  Edge[a].add(b)
  Edge[b].add(a)

set_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)
for i in range(1, N+1):
  print(ans[i])