Harryxun/stf_run huggingface dataset:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}

n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
print(data)

for s in ('S', 'H', 'C', 'D']:
    for r in range(13):
        if cards[s][r] == 0:
            print('{0:s} {1:d}.format(s, r+1))

### FIXED CODE ###

cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
  
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
  
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))
o = input()
e = input()
p = [o[i]+e[i] for i in range(len(o))]
print("".join(p))

### FIXED CODE ###

o = input()
e = input()
if len(o) == len(e):
    print("".join([o[i]+e[i] for i in range(len(o))]))
else:
    print("".join([o[i]+e[i] for i in range(len(e))]+[o[len(o)-1]]))
import math
n =int(input())
h= list(map(int.input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min( dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]) )
print(dp[n-1])
 

### FIXED CODE ###

import math
n =int(input())
h= list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min( dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]) )
print(dp[n-1])
a = input()
t =list(a)
if t[0] == "?":
    if t[1] == "P":
        t[0] = "D"
    else:
        t[0] = "P"
if t[len(t)-1] == "?":
    t[len(t)-1] = "D"
for i in reversed(range(1,len(t)-1)):
    if t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?":
        t[i] = "D"
answer = "".join(t)
print(answer)

### FIXED CODE ###

a = input()
t = list(a)
if t[len(t)-1] == "?":
    t[len(t)-1] = "D"
if t[0] == "?":
    if t[1] == "D" or t[1] == "?":
        t[0] = "P"
    else:
        t[0] = "D"
for i in range(1, len(t)-1):
    if t[i] == "?" and t[i-1] == "P":
        t[i] = "D"
    elif t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?" and t[i+1] == "?":
        t[i] = "P"
    elif t[i] == "?":
        t[i] = "D"

answer = "".join(t)
print(answer)
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

nAC=0
nWA=0
for i in range(N):
    if len(A[i])==0:
        pass
    else:
        j=0 
        while A[i][j]=="WA":
            nWA+=1
            j+=1
            if j>len(A[i]):
                break
            else:
                pass
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
print("{:1},{:2}".format(nAC,nWA))



### FIXED CODE ###

#print("<input>") #
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

#print("<test>") #
#print("A=",A) #

nAC=0
nWA=0
inWA=0
j=0
for i in range(N):
    #print("i=",i) #
    if len(A[i])==0:
        pass
    else: 
        while A[i][j]=="WA":
            inWA+=1
            nWA+=1
            #print("j=",j) #
            #print("inWA=",inWA) #
            #print("nWA=",nWA) #
            if j==len(A[i])-1:
                nWA-=inWA
                break
            else:
                pass
            j+=1
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
        inWA=0
        j=0
        #print("inWA=",inWA) #
        #print("nWA=",nWA) #
        

#print("<ans>") #
print("{0} {1}".format(nAC,nWA))
print(b//x-(a-1)//x)

### FIXED CODE ###

a,b,x=map(int,input().split())
print(b//x-(a-1)//x)
N, X = map(int,input().split())
Ln = map(int,input().split())
cnt = 1
sum = 0
 for i in range(1, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
print(cnt)

### FIXED CODE ###

N, X = map(int,input().split())
Ln = list(map(int,input().split()))
 
cnt = 1
sum = 0
 
for i in range(0, N):
  sum += Ln[i]
  if sum > X:
    break
  cnt += 1
 
print(cnt)
import bisect

ans = 10**20

N, K = list(map(int, input().split()))
x = [-10**20] + list(map(int, input().split())) + [10**20]

zero = bisect.bisect_left(x, 0)

left = x[:zero] + [0] 
right = [0] + x[zero:]
left.reverse()
l = len(left)
r = len(right)

idxs = [[K-i, i] for i in range(K+1) if K-i < l and i < r]

for l, r in idxs:
    n = abs(left[l]) + right[r] + min(abs(left[l]), right[r])
    ans = min(ans, n)
print(ans)

### FIXED CODE ###

def search(idx, a, b, c):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**20
            
    n0 = search(idx+1, a, b, c)
    n1 = search(idx+1, a+l[idx], b, c) + 10
    n2 = search(idx+1, a, b+l[idx], c) + 10
    n3 = search(idx+1, a, b, c+l[idx]) + 10
    
    return min(n0, n1, n2, n3)
    
N, A, B, C = list(map(int, input().split()))
l = [int(input()) for i in range(N)]

print(search(0, 0, 0, 0))
a, b = map(int, input().split())

horizontal_length = b * 2

uncovered_part = a - horizontal_length

if uncovered_part < 0:
  uncovered_part = 0
  
print str(uncovered_part)
  

### FIXED CODE ###

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

horizontal_length = b * 2

uncovered_part = a - horizontal_length

if uncovered_part < 0:
  uncovered_part = 0
  
print(str(uncovered_part))
A,B,K=(int(x) for x in input().split())
GC_list=[]
for i in range(1,max(A,B)):
    if(A%i==0 and B%i==0):
        GC_list.append(i)

print(GC_list[len(GC_list)-K])

### FIXED CODE ###

A,B,K=(int(x) for x in input().split())
GC_list=[]
for i in range(1,max(A,B)+1):
    if(A%i==0 and B%i==0):
        GC_list.append(i)

print(GC_list[len(GC_list)-K])
def main():
    n = int(input())
    p = []
    for _ in range(n):
        p.append(int(input()))
    ans = 0
    add = []
    for i in range(n//2+1):
        if p[i] > n//2:
            ans += 1
            add.append(p[i])
            p[i] = 0
    p += sorted(add)
    P = []
    for p_ in p:
        if p_>0:
            P.append(p_)
    B = P[0:n//2]
    P = P[n//2:]
    m = B[0]
    c = 0
    for i in range(len(B)):
        if B[i]>m:
            m = B[i]
        elif B[i]<m:
            if B[i]>c:
                c = B[i]
    ans += c
    m = P[-1]
    c = 0
    for i in range(len(P)):
        if P[-1-i]<m:
            m = P[-1-i]
        elif P[-1-i]>m:
            if n-P[-1-i]+1>c:
                c = n-P[-1-i]+1
    ans += c
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    p = []
    for _ in range(n):
        p.append(int(input()))
    q = [0 for i in range(n)]
    for i in range(n):
        q[p[i]-1] = i
    m,cnt = 1,1
    for i in range(1,n):
        if q[i]>q[i-1]:
            cnt += 1
            if cnt > m:
                m = cnt
        else:
            cnt = 1
    print(n-m)

if __name__ == "__main__":
    main()
import sys
import math

# 入力
a, b, c = map(int, input().split())
# 計算
if a == (b + 2*c):
    print("1")
else:
    max = math.floor((a + c) / (b + 2*c))
    print(max)

### FIXED CODE ###

X, Y = input().split()

if int(X, 16) > int(Y, 16):
    print(">")
elif int(X, 16) < int(Y, 16):
    print("<")
else:
    print("=")
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[n-1] = n:
    p[n-1], p[n-2] = p[n-2], p[n-1]
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[n-1] == n:
    p[n-1], p[n-2] = p[n-2], p[n-1]
    ans += 1
print(ans)
a = [ int(input()) for i in range(int(input()))]
flag = True
for i in a:
  if i % 2 == 0:
    if i%3 != 0 and i%5 != 0:
      flag = False
      break
print('APPROVED' if flag else 'DENIED')

### FIXED CODE ###

input()
a = list(map(int, input().split()))
flag = True
for i in a:
  if i % 2 == 0:
    if i%3 != 0 and i%5 != 0:
      flag = False
      break
print('APPROVED' if flag else 'DENIED')
s = input()
c = 0
for i in s:
  c += 1
print(s[0] + (c-2) + s[-1])

### FIXED CODE ###

s = input()
print(s[0] + str(len(s)-2) + s[-1])
n,k=list(map(int,input().split()))

result = 0
for i in range(k,n+2):
  numbers = range(0,n+1)
  mins = sum(numbers[0:i])
  maxs = sum(numbers[-i:])
  result += maxs - mins +1


print(result)

### FIXED CODE ###

import math
r = int(input())

l=float(math.pi*2*r)

print(round(l,3))
import math
from collections import Counter

def cmb(n,r):
    if n < r:
        return 0
    else:
        math.factorial(n,r)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([cmb(i,2) for i in count.values()])

    for i in range(len(A)):
        remain = A[:i] + A[i+1:]
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()
N, K = map(int, input().split())
p = list(map(int, input().split()))

s = 0

for j in range(K):
  s += p[j]
  
x = s

for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= t:
    x = t
  else:
    pass
  s = t

print((x + K) / 2)

### FIXED CODE ###

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

if S == U:
  print(A-1, B)
else:
  print(A, B-1)
N = int(input())
u_v_w = [list(map(int, input().split())) for i in range(N-1)]

w = [u_v_w[i][2] for i in range(N-1)]

tree = [[] for i in range(N)]

for i in range(N-1):
    u = u_v_w[i][0]
    v = u_v_w[i][1]
    tree[u-1].append((v,w[i]))
    tree[v-1].append((u,w[i]))

ans = [0] * N
ans[0] = 1
def dfs(now):
    global ans
    for next in tree[now-1]:
        if ans[next[0]-1]:
            continue
        if next[1] % 2 == 0:
            ans[next[0]-1] = ans[now-1]
        else:
            ans[next[0]-1] = ans[now-1] * (-1)
        dfs(next[0])

dfs(1)
for i in range(len(ans)):
    if ans[i] == 1:
        print(0)
    else:
        print(1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)

N = int(input())
u_v_w = [list(map(int, input().split())) for i in range(N-1)]

w = [u_v_w[i][2] for i in range(N-1)]

tree = [[] for i in range(N)]

for i in range(N-1):
    u = u_v_w[i][0]
    v = u_v_w[i][1]
    tree[u-1].append((v,w[i]))
    tree[v-1].append((u,w[i]))

ans = [0] * N
ans[0] = 1
def dfs(now):
    global ans
    for next in tree[now-1]:
        if ans[next[0]-1]:
            continue
        if next[1] % 2 == 0:
            ans[next[0]-1] = ans[now-1]
        else:
            ans[next[0]-1] = ans[now-1] * (-1)
        dfs(next[0])

dfs(1)
for i in range(len(ans)):
    if ans[i] == 1:
        print(0)
    else:
        print(1)
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
students = []
checkpoints = []
for i in range(N):
    students.append(list(map(int, input().split())))
#print(students)
for i in range(M):
    checkpoints.append(list(map(int, input().split())))
#print(checkpoints)
for i in range(N):
    mincp = -1
    mindist = -1
    for j in range(M):
        dist = abs(students[i][0]-checkpoints[j][0]) + abs(students[i][1]-checkpoints[j][1])
        if mincp == -1:
            mincp = j
            mindist = dist
        else:
            if dist < mindist:
                mindist = dist
                mincp = j
    print("%d" % (mincp+1))


### FIXED CODE ###

# -*- coding: utf-8 -*-
A, B = map(int, input().split())
print("%d" % ((A+B)%24))
import sys

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))

# 1 - pi
ans = k
init = p[0]
for i in range(k, len(p)):
    print(i)
    if init < p[i]:
        init = p[i]
        ans = i

exp = 0
for i in range(ans - k + 1, ans + 1):
    exp += p[i]
print('{:.12f}'.format(exp))


### FIXED CODE ###

import sys
import numpy as np

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))
# 1 - pi
# print(p)
p_cumsum = np.cumsum(p)
# print(p_cumsum)
ans = p_cumsum[k-1]

for i in range(0, n - k):
    # print(i, i + k)
    cum = p_cumsum[i + k] - p_cumsum[i]
    ans = max(ans, cum)


print('{:.12f}'.format(ans))
y,m,d=str(input().split("/"))
if y<=2018:
  ans="Heisei"
else:
  if m<=4:
    ans="Heisei"
  else:
    ans="TBD"
print(ans)

### FIXED CODE ###

y,m,d=map(int,input().split("/"))
if y<=2018:
  ans="Heisei"
else:
  if m<=4:
    ans="Heisei"
  else:
    ans="TBD"
print(ans)
l = input()
li = list(map(int, input().split()))
m = 0
for i in range(l):
  n = li[i]
  while not n % 2:
    m += 1
    n /= 2
else:
  print(m)

### FIXED CODE ###

l = int(input())
li = list(map(int, input().split()))
m = 0
for i in range(l):
  n = li[i]
  while not n % 2:
    m += 1
    n /= 2
else:
  print(m)
n, k = input().split()
n = int(n) #友人の数
k = int(k) #基準の高さ
h = input().split()
result = 0
#各人の身長を基準の高さと比較
for i in range(n):
  if k <= int(h[i]):
    result += 1
  else:
    result -= 0
print(result)

### FIXED CODE ###

N = input()
N = int(N)
if N%2 == 0:
  import math
  a = N/2/N  
  print('{:.6f}'.format(a))
else :
  a = (N+1)/2/N
  print('{:.6f}'.format(a))
n,m,x=map(int,input().split(" "))
for i in range(n):
  A[i]=list(map(int,input().split(" ")))

minprice=[-1]
for i in range(m):
  for j in range(n):
    maxi = j
    for k in range(j,n):
      if A[maxi][i] < A[k][i]:
        maxi = k
    temp = A[maxi][i]
    A[maxi][i] = A[j][i]
    A[j][i] = temp
  x_m=0
  p_m
  for j in range(n):
    if x_m < x:
      x_m += A[j][i]
      p_m += A[j][0]
  minprice.append(p_m)
  
print(min(minprice))

### FIXED CODE ###

N,M,X=map(int,input().split())
l=[list(map(int,input().split())) for i in range(N)]


cmin=12*10**5+1
for bit in range(2**N):
    A=[0]*M
    c=0
    for j in range(N):
        if (bit>>j)&1:
            c+=l[j][0]
            A=[x+y for (x,y) in zip(A, l[j][1:])]
    if min(A) >= X:
        cmin=min(cmin,c)

if cmin!=12*10**5+1:
    print(cmin)
else:
    print(-1)
from collections import deque

N = int(input())
H = deque(map(float, input().split()))

prev = H.popleft()

for i in range(N-2):
    cor = H.popleft()
    if prev - cor < -1:
        print('No')
        exit()
    prev = cor

cor = H.popleft()

if cor - prev < 0:
    print('No')
    exit()
    
print('Yes')

### FIXED CODE ###

from collections import deque

N = int(input())
H = deque(map(float, input().split()))

ato = H.pop()

if N == 1:
    print('Yes')
    exit()

for i in range(N-1, 0, -1):
    mae = H.pop()
    if ato - mae < -1:
        print('No')
        exit()
    elif ato - mae == -1:
        ato = mae - 1
    else:
        ato = mae

print('Yes')
s=input()
ans=[]

for i in range(2**3):
  a=int(s[0])
  for j in range(3):
    if ((i>>j)&1):
      a+=int(s[j+1])
    elif ((i>>j)&0):
      a-=int(s[j+1])
      
  if a==7:
    ans.append(i)
    
u=ans[0]
ans1=[]
for j in range(3):
  if ((i>>j)&1):
      ans1.append('+')
  elif ((i>>j)&0):
      ans1.append('-')
      
print(s[0]+ans1[0]+s[1]+ans1[1]+s[2]+ans1[2]+s[3]+'=7')
    

### FIXED CODE ###

s=input()
ans=[]

for i in range(2**3):
  a=int(s[0])
  for j in range(3):
    if ((i>>j)&1):
      a+=int(s[j+1])
    else:
      a-=int(s[j+1])
      
  if a==7:
    ans.append(i)
    
u=ans[0]
ans1=[]
for j in range(3):
  if ((u>>j)&1):
      ans1.append('+')
  else:
      ans1.append('-')
      
print(s[0]+ans1[0]+s[1]+ans1[1]+s[2]+ans1[2]+s[3]+'=7')
S = list(input())
N = len(S) + 1

mn = 0
ans = 0
for s in S:
  if s == '<':
    a += 1
  elif s == '>':
    a -= 1
    mn = min(mn,a)    
  
  ans += a
  
ans -= mn * N
print(ans)


### FIXED CODE ###

S = list(input())
N = len(S) + 1

from_left = [0] * N
from_right = [0] * N

for i in range(N-1):
  s = S[i]
  if s == '<':
    from_left[i+1] = from_left[i] + 1

for i in range(N-2,-1,-1):
  s = S[i]
  if s == '>':
    from_right[i] = from_right[i+1] + 1
    
ans = 0
for i in range(N):
  ans += max(from_left[i],from_right[i])
  
print(ans)
n = input()
k = input()
x = input()
y = input()

return x * n if n < k
return x * k + y * (n - k)

### FIXED CODE ###

n = int(input())
k = int(input())
x = int(input())
y = int(input())

print( x * n if n < k else x * k + y * (n - k) )
hitachi = input()
#type(hitachi)
flag = 0
if(len(hitachi) == 1):
    hitachi += " "
for x in range(len(hitachi)):
    if(x %2 == 0):
        if(hitachi[x] + hitachi[x+1] == "hi"):
            #print(hitachi[x] + hitachi[x+1])
            flag += 1
        else:
            #print(hitachi[x] + hitachi[x+1])
            print("No")
            break
if(flag == len(hitachi)/2):
    print("Yes")

### FIXED CODE ###

hitachi = input()
#type(hitachi)
flag = 0
if(len(hitachi) == 1):
    hitachi += " "
elif(len(hitachi) >= 11):
    hitachi = " "
elif(len(hitachi) % 2 ==1):
    hitachi += " "
for x in range(len(hitachi)):
    if(hitachi[x] == " "):
        break
    if(x %2 == 0):
        if(hitachi[x] + hitachi[x+1] == "hi"):
            #print(hitachi[x] + hitachi[x+1])
            flag += 1
        else:
            #print(hitachi[x] + hitachi[x+1])
            print("No")
            break
if(not len(hitachi) == 0):
    if(flag == len(hitachi)//2):
        print("Yes")
a, b, k = map(int, input().split())

min = a
if b < min:
  min = b

ans_lists = []
for i in range(1, min+1, 1):
  if a%i == 0 and b%i == 0:
    ans_lists.append(i)

ans_lists.reverse()
ans = lists[k-1]

print(ans)

### FIXED CODE ###

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

min = a
if b < min:
  min = b

ans_lists = []
for i in range(1, min+1, 1):
  if a%i == 0 and b%i == 0:
    ans_lists.append(i)

ans_lists.reverse()
ans = ans_lists[k-1]

print(ans)
import sys
import numpy as np
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    h, w, m = MII()
    bombs = [MIIZ() for _ in range(m)]
    area = np.zeros((h,w), dtype=int)
    # print(area)
    for x, y in bombs:
        area[x:x+1, :] += 1
        area[:, y:y+1] += 1
        area[x:x+1, y:y+1] -= 1
        # print(area)
    print(area.max())

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import numpy as np
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    h, w, m = MII()
    bombs = [MIIZ() for _ in range(m)]
    a = [0]*h
    b = [0]*w
    for y,x in bombs:
        a[y] += 1
        b[x] += 1
    maxa = max(a)
    maxb = max(b)
    sumv = maxa + maxb
    c = a.count(maxa)*b.count(maxb) - sum(a[y]+b[x] == sumv for y,x in bombs)
    print(sumv - (c<=0))

if __name__ == '__main__':
    main()
n, q = map(int,input().split())
nodes = [[[], 0] for _ in range(n)]

def add(idx, val):
    global nodes
    nodes[idx][1] += val
    for n in nodes[idx][0]:
        add(n, val)

for _ in range(n-1):
    a, b = map(int, input().split())
    nodes[a-1][0].append(b-1)
for _ in range(q):
    p, q = map(int, input().split())
    add(p-1, q)
op = str(nodes[0][1])
for n in range(1, len(nodes)):
    op += " {}".format(nodes[n][1])
print(op)


### FIXED CODE ###

n, q = map(int,input().split())
nodes = [[[], 0] for _ in range(n)]

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

search_node = [0]

while len(search_node) > 0:
    n = search_node.pop()
    for i in nodes[n][0]:
        nodes[i][1] += nodes[n][1]
        search_node.append(i)


op = str(nodes[0][1])
for n in range(1, len(nodes)):
    op += " {}".format(nodes[n][1])
print(op)
# ABC 106
def db(x): 
    global debug
    if debug: print(x)
debug = False
S = input()
K = int(input())
c5000 = 5*10**15
k = 0
for i in range(100):
    n = ord(S[i])-ord('0')
    if n>1: n *= c5000
    k += n
    db((i,k))
    if k>=K:
          print(S[i])
          break



### FIXED CODE ###

# ABC 106
def db(x): 
    global debug
    if debug: print(x)
debug = False
S = input()
K = int(input())
for i in range(len(S)):
    if S[i]!='1': break
if i>=K: print('1')
else:   print(S[i])
while True:
    try:
        N, Q = map(int, input().split())
        verts = [None] * N
        results = [0] * N
        for i in range(N - 1):
            a, b = map(int, input().split())
            if a == 1:
                continue
            a -= 1
            if verts[a] is None:
                verts[a] = list()
            verts[a].append(b)
        for i in range(Q):
            q, x = map(int, input().split())
            q-= 1
            results[q] += x
            if q == 0:
                for i in range(1, N):
                    results[i] += x
            elif verts[q] is not None:
                rests = verts[q][:]
                while rests:
                    i = rests.pop(0)
                    results[i-1] += x
                    if verts[i-1] is not None:
                        rests.extend(verts[i])
        print(" ".join(map(str, results)))
    except EOFError:
        break

### FIXED CODE ###

while True:
    try:
        N, Q = map(int, input().split())
        verts = [None] * N
        qs = [0] * N
        results = [0] * N
        for i in range(N - 1):
            a, b = map(int, input().split())
            a -= 1
            b -= 1
            if verts[a] is None:
                verts[a] = list()
            if verts[b] is None:
                verts[b] = list()
            verts[a].append(b)
            verts[b].append(a)
        for i in range(Q):
            q, x = map(int, input().split())
            q -= 1
            qs[q] += x
        rests = [(0, None)]
        while rests:
            x, parent = rests.pop()
            if parent is not None:
                results[x] += results[parent]
            results[x] += qs[x]
            for i in verts[x]:
                if i != parent:
                    rests.append((i, x))
        print(" ".join(map(str, results)))
    except EOFError:
        break