Harryxun/stf_run huggingface dataset:
S = input()
K = int(input())

output = ''

if len(S) <= K:
    for letter in S:
        if letter != '1':
            output = l
            break
else :
    for i in range(K):
        if S[i] != '1':
            output = S[i]
            break
    
if output:
    print(output)
else :
    print('1')

### FIXED CODE ###

S = input()
K = int(input())

output = ''

if len(S) <= K:
    for letter in S:
        if letter != '1':
            output = letter
            break
else :
    for i in range(K):
        if S[i] != '1':
            output = S[i]
            break

if output:
    print(output)
else :
    print('1')
a,b,c,d=map(int,input().split())
if a>=0 and b>=0 and c>=0 and d>=0:
  print(b*d)
elif a<=0 and b>=0 and c>=0 and d>=0:
  print(b*d)
elif a<=0 and b<=0 and c>=0 and d>=0:
  print(b*c)
elif a<=0 and b>=0 and c<=0 and d>=0:
  print(b*d)
elif a<=0 and b<=0 and c<=0 and d>=0:
  print(a*c)
elif a<=0 and b>=0 and c<=0 and d<=0:
  print(a*c)
elif a<=0 and b<=0 and c<=0 and d<=0:
  print(a*c)

### FIXED CODE ###

X=int(input())
if X==0:
  print(1)
else:
  print(0)
def S(num):
  ret=0
  for i in range(9):
    ret+=int((num%(10**(i+1)))/(10**i))
  return ret

n=int(input())
a=S(n)
if n%a == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

def S(num):
  ret=0
  for i in range(10):
    ret+=int((num%(10**(i+1)))/(10**i))
  return ret

n=int(input())
a=S(n)
if n%a == 0:
  print('Yes')
else:
  print('No')
no=int(input())
n=no
c=0
while(n):
  if n == 0:
    print c/n
    break
  if n%2 == 1:
    c += 1

### FIXED CODE ###

no=int(input())
n=no
c=0
while(n>0):
  if n%2 == 1:
    c += 1
  n -= 1
print(c/no)
X = int(input())
k = 1
n = 1

while true:
  ans = 360 * n % X
  if ans == 0:
    print(360 * n / X)
    break;
  else:
    n += 1


### FIXED CODE ###

X = int(input())
i = 1

while (360*i) % X != 0:
  i += 1
ans = 360*i//X
print(ans)
import sys
sys.setrecursionlimit(10000000)

s = input()
n = len(s)

mod=10**9+7

dp = [[0] * 13 for _ in range(10**5) ]

ans=0
dp[0][0] =1

for i in range(n):
    if s[i] == '?':c=-1
    else: c=int(s[i])

    for j in range(10):
        if (c == -1 or c== j):
            for ki in range(13):
                dp[i+1][(ki*10+j)%13] += dp[i][ki]

    # for j in range(13):
    #     dp[i+1][j] %= mod

print(dp[n][5]%mod%mod)

### FIXED CODE ###

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

dp=[[0]*13 for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    if s[i]=="?":
        for k in range(10):
            for j in range(13):
                p=(k+10*j)%13
                dp[i+1][p]+=dp[i][j]
                dp[i+1][p]%=mod

    else:

        for j in range(13):
            p=(int(s[i])+10*j)%13
            dp[i+1][p]+=dp[i][j]
            dp[i+1][p]%=mod


print(dp[n][5])
a=int(input()) 
print(a+a*a+a**3)　

### FIXED CODE ###

a=int(input())
print(a+a*a+a**3)
N = int(input())
h = list(map(int, input().split()))
DP = [10000]*7
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(N-1):
  DP[i+1] = abs(h[i+1]-h[i])+DP[i]
  if i > 0:
    DP[i+1] = min(abs(h[i+1]-h[i])+DP[i], abs(h[i+1]-h[i-1])+DP[i-1])
print(DP)

### FIXED CODE ###

N = int(input())
h = list(map(int, input().split()))
DP = [10000]*N
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(N-1):
  DP[i+1] = abs(h[i+1]-h[i])+DP[i]
  if i > 0:
    DP[i+1] = min(abs(h[i+1]-h[i])+DP[i], abs(h[i+1]-h[i-1])+DP[i-1])
print(DP[N-1])
n = int(input())
s = input()

s = list(s)

l1 = 'abcdefghijklmnopqrstuvwxyz'
l1 = list(l1)

l2 = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
l2 = list(l2)

s1 = [0]*len(s)
s2 = [0]*len(s)

for i in range(len(s)):
	s1[i] = l1.index(s[i])

for i in range(len(s)):
	s2[i] = l2[s1[i]+n] 

#リスト１つずつくっつけて文字列にする
ans = ''
for i in range(len(s2)):
	ans = ans + s2[i]

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

s = list(s)

l1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
l1 = list(l1)

l2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
l2 = list(l2)

s1 = [0]*len(s)
s2 = [0]*len(s)

for i in range(len(s)):
	s1[i] = l1.index(s[i])

for i in range(len(s)):
	s2[i] = l2[s1[i]+n] 

#リスト１つずつくっつけて文字列にする
ans = ''
for i in range(len(s2)):
	ans = ans + s2[i]

print(ans)
a=input())
if a[2] == a[3] and a[4] == a[5]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a=input()
if a[2] == a[3] and a[4] == a[5]:
  print("Yes")
else:
  print("No")
### Pythonのバージョンが3.4.3なのでmath.gcd(*, *)がエラーとなるらしい。
from fractions import gcd

def prime_factorization(n):
    s = math.floor(math.sqrt(n)) # 平方根を小数点切り捨て
    ans = [] # [素数, 指数]のリスト

    # 2からsまでの素因数を求める
    for i in [2] + list(range(3, s + 1, 2)):
        if n < i:
            break
        if n % i == 0:
            r = 0 # 指数カウンタクリア
            while n % i == 0:
                r += 1
                n //= i
            ans.append([i, r])

    # 残った素数を追加
    if n > s:
        ans.append([n, 1])

    return(ans)


A, B = [int(a) for a in input().split()]

# d = gcd(A, B) = p_1^(e_1) + p_2^(e_2) + ... + p_k^(e_k)
# と素因数分解できる場合、答えは k + 1
d = gcd(A, B)
pf = prime_factorization(d)
print(len(pf) + 1)


### FIXED CODE ###

### Pythonのバージョンが3.4.3なのでmath.gcd(*, *)がエラーとなるらしい。
import fractions
import math

def prime_factorization(n):
    s = math.floor(math.sqrt(n)) # 平方根を小数点切り捨て
    ans = [] # [素数, 指数]のリスト

    # 2からsまでの素因数を求める
    for i in [2] + list(range(3, s + 1, 2)):
        if n < i:
            break
        if n % i == 0:
            r = 0 # 指数カウンタクリア
            while n % i == 0:
                r += 1
                n //= i
            ans.append([i, r])

    # 残った素数を追加
    if n > s:
        ans.append([n, 1])

    return(ans)


A, B = [int(a) for a in input().split()]

# d = gcd(A, B) = p_1^(e_1) + p_2^(e_2) + ... + p_k^(e_k)
# と素因数分解できる場合、答えは k + 1
d = fractions.gcd(A, B)
pf = prime_factorization(d)
print(len(pf) + 1)
N,A,B=[ int(x) for x in input().split()]
if N == 1:
    print("Hello,world")
	
else:
    print(A+B)
	

### FIXED CODE ###

if int(input()) == 1:
    print("Hello World")

else:	
    A=int(input())
    B=int(input())
    print(A+B)
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

for x in range(1000):
    ok = True
    s = str(x)
    if len(s) != n:
        continue
    if not all([int(s[a[i][0] - 1]) == a[i][1] for i in range(m)]):
        continue
    print(x)
    exit(1)

print(-1)


### FIXED CODE ###

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

for x in range(1000):
    ok = True
    s = str(x)
    if len(s) != n:
        continue
    if not all([int(s[a[i][0] - 1]) == a[i][1] for i in range(m)]):
        continue
    print(x)
    exit(0)

print(-1)
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=d[i*w+j];p=d[s]+1
   if(h>i>-1<j<w)-1or'.'<m[i][j]or t<p:break
   if t>p:q+=t,;d[i*w+j]=p
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   if d[t]==I:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)
print(input().count()*3 +700)

### FIXED CODE ###

print((input().count("o"))*100+700)
n=int(input())
ans=0
for i in range(0,n):
  s=input().split()
  s[i]=''.join(sorted(s))
  
for j in range(0,n-1):
  for k in range(j+1,n):
    if li[j]==li[k]:
      ans+=1
    else:
      ans+=0
      
print(ans)      


### FIXED CODE ###

n=int(input())
dic={}
for _ in range(0,n):
  s="".join(sorted(input()))
  if s in dic:
    dic[s]+=1
  else:
    dic[s]=1
    
ans=0    
for a in dic.values():
  ans+=(a*(a-1))/2
  
print(int(ans))
#!usr/bin/env python3
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LIR(n):
    return [LI() for i in range(n)]

def solve():
    def add(i,x):
        while i < len(bit):
            bit[i] += x
            i += i&-i
    def sum_(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res
    n,Q = LI()
    c = LI()
    c = [0]+c
    q = [[i]+LI() for i in range(Q)]
    q.sort(key = lambda x:x[1][1])
    bit = [0]*(n+2)
    i = 1
    p = [None]*(n+1)
    ans = [0]*Q
    s = 0
    for ind,(l, r) in q:
        l -= 1
        while i <= r:
            ci = c[i]
            j = p[ci]
            if j is not None:
                add(j,1)
            else:
                s += 1
            p[ci] = i
            i += 1
        ans[ind] = s-l+sum_(l)
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def LIR(n):
    res = [None] * n
    for i in range(n):
        l, r = map(int, input().split())
        res[i] = (l-1, r-1, i)
    return res

#solve
def solve():
    n, q = LI()
    c = LI()
    lr = LIR(q)
    ans = [None] * q
    lr.sort(key=lambda x: x[1])
    dp = [-1] * (max(c) + 1)
    bit = [0] * (n + 1)
    def add(i, w):
        """
        i番目にwを加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= n:
            bit[x - 1] += w
            x += x & -x
        return
    def sum(i):
        """
        [0,i]の合計
        :param int i:
        :return:
        """
        res = 0
        x = i + 1
        while x > 0:
            res += bit[x - 1]
            x -= x & -x
        return res
    t = 0
    def f(t):
        l, r, j = lr[t]
        xr = sum(r)
        xl = sum(l-1)
        tmp = xr - xl
        ans[j] = tmp
        
    for i in range(n):
        ci = c[i]
        l = dp[ci]
        add(i, 1)
        dp[ci] = i
        if l != -1:
            add(l, -1)
        while t < q and lr[t][1]<= i:
            f(t)
            t += 1
        if t == q:
            break
    for ai in ans:
        print(ai) 
    return


#main
if __name__ == '__main__':
    solve()
n = int(input());
w = list(map(int, input().split()))

sum_list = sum(w);
sum_list2 = sum_list/2;

sum_of_all = 0;
i = 0;
while sum_of_all <sum_list2:
  sum_of_all += sum_list[i];
  i=i+1;
  
print(abs((sum_list-sum_of_all)-sum_of_all))

### FIXED CODE ###

N = int(input())
W = list(map(int, input().split()))
 
sum_W = sum(W)
add_W = 0
 
for i in range(N):
   add_W += W[i]
   if add_W >= sum_W - add_W:
       print(min(abs(add_W - sum_W + add_W), abs(add_W - W[i] - sum_W + add_W - W[i])))
       break
import math

A,B,C,D = map(int,input().split())

gcd = math.gcd(C,D)
lcm = int(C*D/gcd)

ans_A = int((A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm)
ans_B = int(B - B//C - B//D + B//lcm)
print(ans_B - ans_A)


### FIXED CODE ###

import fractions

A,B,C,D = map(int,input().split())

gcd = fractions.gcd(C,D)
lcm = int(C*D/gcd)

ans_A = int((A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm)
ans_B = int(B - B//C - B//D + B//lcm)
print(ans_B - ans_A)
return a*b // gcd(a, b)
"""
akが偶数だから、bk=2akとして、
bk × (2p + 1)を満たすpが存在すれば良い
2p+1は奇数のため、Xとbkの2の素因数は一致しなければならない
akに含まれる最大の2^kを探す。
"""
lcm_all = lcm(a[0]//2, a[1]//2)
amax = 0
for i in range(1, n):
    lcm_all = lcm(lcm_all, a[i]//2)
    amax = max(amax, a[i]//2)

f = True
if lcm_all > m:
    f = False
for i in range(n):
    if (lcm_all//(a[i]//2))%2 == 0:
        # akの2の約数の数がそろわないので、どんな奇数を掛けても共通のXを作れない
        f = False
if f:
    # amaxの奇数倍でmを超えないもの
    ans = (m // lcm_all + 1)//2
    print(ans)
else:
    print(0)

### FIXED CODE ###

from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))

def lcm(a, b):
    return a*b // gcd(a, b)
"""
akが偶数だから、bk=2akとして、
bk × (2p + 1)を満たすpが存在すれば良い
2p+1は奇数のため、Xとbkの2の素因数は一致しなければならない
akに含まれる最大の2^kを探す。
"""
if len(a) == 1: lcm_all = a[0]//2
else: lcm_all = lcm(a[0]//2, a[1]//2)
amax = 0
for i in range(1, n):
    lcm_all = lcm(lcm_all, a[i]//2)
    amax = max(amax, a[i]//2)

f = True
if lcm_all > m:
    f = False
for i in range(n):
    if n == 1: break
    if (lcm_all//(a[i]//2))%2 == 0:
        # akの2の約数の数がそろわないので、どんな奇数を掛けても共通のXを作れない
        f = False
if f:
    # amaxの奇数倍でmを超えないもの
    ans = (m // lcm_all + 1)//2
    print(ans)
else:
    print(0)
# sys.stdin.readline()
import sys
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    l=list(map(int,input().split()))
    l2 = [(1+i)/2 for i in l]
    kitai=sum(l2[0:k])
    tmp = kitai
    for idx in range(n)[:n - k + 1]:
        tmp -= l2[idx]
        tmp += l2[idx+k]
        if (kitai < tmp):
           kitai = tmp
    print(kitai)
main()

### FIXED CODE ###

# sys.stdin.readline()
import sys
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    l=list(map(int,input().split()))
    l2 = [(1+i)/2 for i in l]
    kitai=sum(l2[0:k])
    tmp = kitai
    for idx in range(n)[:n - k]:
        tmp -= l2[idx]
        tmp += l2[idx+k]
        if (kitai < tmp):
           kitai = tmp
    print(kitai)
main()
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())
            a -= 1
            b -= 1
            if verts[a] is None:
                verts[a] = list()
            verts[a].append(b)

        maxmap = [None] * N
        map_a = [None] * N
        map_b = [None] * N
        def trav(a, x):
            map_a[a] = x
            map_b[x] = a
            if verts[a] is None:
                return x
            for i in verts[a]:
                maxmap[i] = x = trav(i, x + 1)
            return x

        maxmap[0] = trav(0, 0)

        for i in range(Q):
            q, x = map(int, input().split())
            q-= 1
            if q == 0:
                for i in range(N):
                    results[i] += x
            elif verts[q] is not None:
                for i in range(map_a[q], maxmap[q] + 1):
                    results[i] += x
            else:
                results[q] += x
        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
lst=list(input().split())
lst.sort()
if lst[0]==lst[1]==lst[2]==lst[3]andlst[4]==lst[5]==lst[6]==lst[7]andlst[8]==lst[9]==lst[10]==lst[11]:

  print('yes')
else:
   print('no')

### FIXED CODE ###

l=list(input().split())
l.sort()
if l[0]==l[1]==l[2]==l[3] and l[4]==l[5]==l[6]==l[7]and l[8]==l[9]==l[10]==l[11]:
  print('yes')
else:
   print('no')
num = input()
list = list(map(int,input().split()))
flg  = False
for i in list:
  if list.count(i) >= 2:
	flg = True
	break
print("NO") if flg else print("YES")


### FIXED CODE ###

num = input()
list = list(map(int,input().split()))
list2 = set(list) 
print("YES") if len(list) == len(list2) else print("NO")
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

mod=10**9+7
zero=0
counter0=defaultdict(int)
counter1=defaultdict(int)
N=int(input())
for i in range(N):
    x,y=nm()
    if(x==0 and y==0):
        zero+=1
        continue
    g=fractions.gcd(x,y)
    x/=g
    y/=g
    if(y<0):
        x=-x
        y=-y
    if(y==0 and x<0):
        x=-x
        y=-y
    rot90=False
    if(x<0):
        rot90=True
    if(rot90):
        tmp = x
        x=y
        y=-tmp
    if(rot90):
        counter0[(x,y)]+=1
    else:
        counter1[(x,y)]+=1
        counter0[(x,y)]+=0

ans=1
for key,cnt0 in counter0.items():
    cnt1=counter1[key]
    now=1
    now+=2**cnt0-1
    now+=2**cnt1-1
    now%=mod
    ans*=now
    ans%=mod
        
ans+=zero
ans-=1

print(ans%mod)






### FIXED CODE ###

import sys
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
if(N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9):
    print('hon')

if(N%10==0 or N%10==1 or N%10==6 or N%10==8 ): 
    print('pon')

if(N%10==3): 
    print('bon')
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scanln(&s)
	r := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	words := [][]rune{[]rune("maerd"), []rune("remaerd"), []rune("esare"), []rune("resare")}
	for {
		if len(r) == 0 {
			fmt.Println("YES")
			return
		}
		fail := 0
		for _, w := range words {
			if strings.HasPrefix(r, w) {
				r = r[len(w):]
				break
			} else {
				fail++
			}
		}
		if fail == len(words) {
			fmt.Println("NO")
			return
		}
	}
}


### FIXED CODE ###

import sys
s = raw_input()
ts = ['']
while True:
  nts= []
  for t in ts:
    for w in ['dreamer', 'eraser', 'dream', 'erase']:
      if s == t + w:
        print 'YES'
        sys.exit()
      if s.startswith(t + w):
        nts.append(t + w)
  if len(nts) == 0:
    print 'NO'
    sys.exit()
  ts = nts
print("Even" if int(input()) * int(input()) % 2 == 0 else "odd")

### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")
import math
a=b=1
l=[i for i in range(1,N+1)]
m=[i for i in range(1,N+1)]
for i in range(N):
  #print("===P[i]===", P[i])
  #print(l.index(P[i]), math.factorial(N-i-1))
  a += l.index(P[i])*math.factorial(N-i-1)
  #print("l", l)
  if not i==N-1:
    l.pop(l.index(P[i]))
for i in range(N):
  b += m.index(Q[i])*math.factorial(N-i-1)
  if not i==N-1:
    m.pop(m.index(Q[i]))
print(abs(a-b))


### FIXED CODE ###

import math
N=int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
a=b=1
l=[i for i in range(1,N+1)]
m=[i for i in range(1,N+1)]
for i in range(N):
  #print("===P[i]===", P[i])
  #print(l.index(P[i]), math.factorial(N-i-1))
  if N-i-1 < 0:
    pass
  else:
    a += l.index(P[i])*math.factorial(N-i-1)
  #print("l", l)
  if not i==N-1:
    l.pop(l.index(P[i]))
for i in range(N):
  if N-i-1 < 0:
    pass
  else:
    b += m.index(Q[i])*math.factorial(N-i-1)
  if not i==N-1:
    m.pop(m.index(Q[i]))
print(abs(a-b))
a = input()
s = input()
print(s if a >= 3200 else "red")

### FIXED CODE ###

a = int(input())
s = input()
print(s if a >= 3200 else "red")
K=input()
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[K])

### FIXED CODE ###

K=int(input())
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[K-1])
import sys

sys.setrecursionlimit(30000)

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

costs = [0 for i in range(n)]
visited = [False for _ in range(n)]


def rec(prev_v, v, value):
    if visited[v]:
        return
    visited[v] = True
    next_value = value + xs[v]
    costs[v] = next_value
    for next_v in g[v]:
        if next_v == prev_v:
            continue
        rec(v, next_v, next_value)


rec(-1, 0, 0)
print(' '.join(map(str, costs)))



### FIXED CODE ###

import sys

n, q = map(int, sys.stdin.readline().split())
g = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
xs = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    p -= 1
    xs[p] += x

visited = [False for _ in range(n)]
# def rec(prev_v, v, value):
#     if visited[v]:
#         return
#     visited[v] = True
#     next_value = value + xs[v]
#     costs[v] = next_value
#     for next_v in g[v]:
#         if next_v == prev_v:
#             continue
#         rec(v, next_v, next_value)
# rec(-1, 0, 0)

current_node = [0]
while len(current_node) > 0:
    next_node = []
    for v in current_node:
        visited[v] = True
        for next_v in g[v]:
            if visited[next_v]:
                continue
            next_node.append(next_v)
            xs[next_v] += xs[v]
    current_node = next_node

print(' '.join(map(str, xs)))
# 入力
a = int(input())
op = input()
b = int(input())

# 処理
if op == '+':
    answer = a + b
elif op == '-':
    answer = a - b
    
# 出力
print(answer)

### FIXED CODE ###

# 入力
a, op, b = map(str, input().split())
a = int(a)
b = int(b)

# 処理
if op == '+':
    answer = a + b
elif op == '-':
    answer = a - b

# 出力
print(answer)
n, m = map(int, input().split())
a = list(map(int, input().split()))

play=n-sum(a)
if play < 0: play=-1
 

print (play)

### FIXED CODE ###

import numpy as np
i = int(input())
pi = np.pi
print (2*pi*i)
"""

"""
INF = 10 ** 20

N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**10
 
dp = [INF]*N
dp[0] = 0
 
for i,hi in enumerate(h):
    if i == 0:
        continue
    s = i-K if i-K >= 0 else 0
    dp[i] = min([dpk + abs(hi-hk) for dpk,hk in zip(dp[i-K:i],h[i-K:i])])
 
print(dp[-1])

### FIXED CODE ###

N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**10
 
dp = [INF]*N
dp[0] = 0
 
for i,hi in enumerate(h):
    if i == 0:
        continue
    s = i-K if i-K >= 0 else 0
    dp[i] = min([dpk + abs(hi-hk) for dpk,hk in zip(dp[s:i],h[s:i])])
 
print(dp[-1])
#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for _ in range(M):
    b, c = list(map(int, input().split()))
    bc_list.append((b, c))

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
now_list = np.array(sorted(a_list))
fix_list = np.array([])
min_a = min(a_list)

for bc in bc_list:
    b, c = bc
    if min_a >= c:
        # もう置き換えても合計値は増えない
        break
    # cより小さい数は何個あるか？
    # 線形探索だとTLEになるので、2分探索で考える
    c_index = bisect.bisect_right(now_list, c)
    target_index = c_index if c_index < b else b

    # c_indexまでをcで置き換えても、順序の入れ替えはない
    now_list[:target_index] = c
    # c_index以前の整数は使用確定なので掃き出す
    fix_list = np.hstack([fix_list, now_list[:target_index]])
    now_list = now_list[target_index:]
    min_a = now_list[0]

fix_list = np.hstack([fix_list, now_list])
ans = fix_list.sum()
ans = int(ans)
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for i in range(M):
    try:
        b, c = list(map(int, input().split()))
        bc_list.append((b, c))
    except:
        M = i

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
a_list = sorted(a_list)

fix_list = []
s = 0
b, c = bc_list[0]
bc_index = 0
now_b, now_c = 0, c

for i, a in enumerate(a_list):
    # a = a_list[i]
    if now_b >= b:
        bc_index += 1
        if bc_index >= len(bc_list):
            # TODO: 残りを足す
            fix_list.append(a)
            s += a
            continue
        now_b = 0
        b, c = bc_list[bc_index]

    if a < c:
        fix_list.append(c)
        s += c
    else:
        fix_list.append(a)
        s += a
    now_b += 1

ans = s
print(ans)