Harryxun/stf_run huggingface dataset:
import sys

n, q = map(int, sys.stdin.readline().split())
counter = [0 for _ in range(n)]
relation = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    relation[a-1].append(b-1)
operate = [list(map(int, sys.stdin.readline().split())) for _ in range(q)]

def dfs(start, point):
    visited[start] = True
    for node in relation[start]:
        if visited[node] == False:
            counter[node] += point
            dfs(node, point)

for ope in operate:
    start, point = ope
    start -= 1
    counter[start] += point
    visited = [False for _ in range(n)]
    dfs(start, point)

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


### FIXED CODE ###

from collections import deque

n, q = map(int,input().split())
g = [[] for _ in range(n)] # グラフを格納
count = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1) # どちらが根かわからない

for _ in range(q):
    p, x = map(int, input().split())
    count[p-1] += x

que = deque()
que.append(0)

watch = [False] * n
watch[0] = True

while que:
    i = que.popleft()
    watch[i] = True
    for e in g[i]:
        if watch[e] == True: continue
        count[e] += count[i]
        que.append(e)

print(" ".join(map(str, count)))
from itertools import product
S = input()
if len(S)==1:
    print(int(S))
else:
    Sum = 0
    for TR in product([0,1],repeat=(len(S)-1)):
        Op = ['+' if TO==1 else '' for TO in TR]+['']
        Sum += eval(''.join([TS+TO for TS,TO in zip(S,Op)]))
print(Sum)

### FIXED CODE ###

from itertools import product
S = input()
if len(S)==1:
    print(int(S))
else:
    Sum = 0
    for TR in product([0,1],repeat=(len(S)-1)):
        Op = ['+' if TO==1 else '' for TO in TR]+['']
        Sum += eval(''.join([TS+TO for TS,TO in zip(S,Op)]))
    print(Sum)
from fractions import gcd
import math

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


def lcm(x, y):
    if math.gcd(x, y) == 0:
        return x * y
    return x * y // gcd(x, y)


def cantdiv(x):
    return x - x // c - x // d + x // lcm(c, d)


print(cantdiv(b) - cantdiv(a - 1))


### FIXED CODE ###

from fractions import gcd

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


def lcm(x, y):
    if gcd(x, y) == 0:
        return x * y
    return x * y // gcd(x, y)


def cantdiv(x):
    return x - x // c - x // d + x // lcm(c, d)


print(cantdiv(b) - cantdiv(a - 1))
import sys
sys.setrecursionlimit(10**9)

input = sys.stdin.readline

N = int(input())
T = [[] for _ in range(N+1)]

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

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

dist = [None]*(N+1)

def dfs(now,d) :
    dist[now] = d
    for to,c in T[now] :
        if dist[to] is not None :
            continue
        dfs(to,d+c)

dfs(K,0)

ans = [0]*Q

for _ in range(Q) :
    u,v = map(int,input().split())
    ans[i] = dist[u]+dist[v]

print(*ans,sep="\n")


### FIXED CODE ###

from collections import deque

N = int(input())

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

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

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

K -= 1

DISTANCE = [float("inf") for i in range(N)]

DISTANCE[K] = 0

q = deque([K])

while q :
    from_ = q.popleft()
    for to_, weight in L[from_] :
        dist = DISTANCE[from_] + weight
        if dist < DISTANCE[to_] :
            DISTANCE[to_] = dist
            q.append(to_)
            
ans = []

for i in range(Q) :
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    
    calc = DISTANCE[x] + DISTANCE[y]
    ans.append(calc)

print(*ans, sep="\n")
A, B = input().split()
print(A*B)

### FIXED CODE ###

A, B = map(int, input().split())
print(A*B)
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
s.remove(a)
s.remove(a)
b = s[0]
if s.count(b) != 2:
  print("No")
  sys.exit()
print("Yes")

### FIXED CODE ###

import sys
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
t = s.replace(a,"")

if t[0] != t[1]:
  print("No")
else:
  print("Yes")
def func():
	n = input("")
	bruh = []
	for i in range(n):
		var = input("")
		bruh.append(var)
	bruh = list(dict.fromkeys(bruh))
	return len(bruh)
print(func())

### FIXED CODE ###


def func():
	n = int(input(""))
	bruh = []
	for i in range(n):
		var = input("")
		bruh.append(var)
	bruh = list(dict.fromkeys(bruh))
	return len(bruh)
print(func())
N,M = map(int,input().split())
pos=["-"]*N
if M==0:
  print("Yes")
  exit()
elif N==1:
  print("Yes")
  exit()
else:
  l,r,d=map(int,input().split())
pos[l-1]=0
pos[r-1]=pos[l-1]+d
for i in range(1,M):
  l,r,d=map(int,input().split())
  if pos[r-1]=="-":
    pos[r-1] = pos[l-1]+d
  elif pos[r-1]==pos[l-1]+d:
    continue
  else:
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N,M = map(int,input().split())
G = [[] for _ in [0]*N]

for _ in [0]*M:
  a, b, d = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append((b, d))
  G[b].append((a, -d))

X = [None]*N

def dfs(i, x=0):
  for j, d in G[i]:
    if X[j] is None:
      X[j] = x+d
      dfs(j, x+d)
    elif X[j] != x+d:
      print('No')
      exit()

for i in range(N):
  if X[i] is not None:
    continue
  X[i] = 0
  dfs(i)
print('Yes')
l=[list(map(int,input().split())) for i in range(3)]
n=int(input())
H=[0,0,0]
W=[0,0,0]
S=[0,0]
 
for i in range(n):
    b=int(input())
    for h in range(3):
        for w in range(3):
            if b==l[h][w]:
                H[h]+=1
                W[w]+=1
                if h==w:
                    S[0]+=1
                if h+w==4:
                    S[1]+=1
 
check=False
for h in H:
    if h==3:
        check=True
for w in W:
    if w==3:
        check=True
for s in S:
    if s==3:
        check=True
 
if check:
    print("Yes")
else:
    print("No")
l=[list(map(int,input().split())) for i in range(3)]
n=int(input())
H=[0,0,0]
W=[0,0,0]
S=[0,0]

for i in range(n):
    b=int(input())
    for h in range(3):
        for w in range(3):
            if b==l[h][w]:
                H[h]+=1
                W[w]+=1
                if h==w:
                    S[0]+=1
                if h+w==2:
                    S[1]+=1

check=False
for h in H:
    if h==3:
        check=True
for w in W:
    if w==3:
        check=True
for s in S:
    if s==3:
        check=True

if check:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

l=[list(map(int,input().split())) for i in range(3)]
n=int(input())
H=[0,0,0]
W=[0,0,0]
S=[0,0]

for i in range(n):
    b=int(input())
    for h in range(3):
        for w in range(3):
            if b==l[h][w]:
                H[h]+=1
                W[w]+=1
                if h==w:
                    S[0]+=1
                if h+w==2:
                    S[1]+=1

check=False
for h in H:
    if h==3:
        check=True
for w in W:
    if w==3:
        check=True
for s in S:
    if s==3:
        check=True

if check:
    print("Yes")
else:
    print("No")
#import math
import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
#import collections

D=int(input())
#N,M,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
C = list(map(int,input().split()))
#S=str(input())
c=np.zeros(365)
l=np.zeros([26,365])
T=[]
for i in range(D):
    S = map(int,input().split())
    t=max(S)
    T.append(S.index(t))
    #for i in range(26):
    #    n=
for s in T:
    print(s)


### FIXED CODE ###

#import math
import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
#import collections

D=int(input())
#N,M,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
C = list(map(int,input().split()))
#S=str(input())
c=np.zeros(365)
l=np.zeros([26,365])
T=[]
for i in range(D):
    S = list(map(int,input().split()))
    t=max(S)
    T.append(S.index(t))
    #for i in range(26):
    #    n=
for s in T:
    print(s+1)
a,b,c = map(int,input().split())

if(a<b && b<c):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if(a<b & b<c):
    print("Yes")
else:
    print("No")
a=input()
n=len(a)
count=0
for i in range(n):
	 if a[i]!=a[n+1-i]:
	 	a[i]=a[n+1-i]
	 	count+=1
print(count)

### FIXED CODE ###

a=list(input())
n=len(a)
count=0
for i in range(n):
	 if a[i]!=a[n-1-i]:
	 	a[i]=a[n-1-i]
	 	count+=1
print(count)
a = int(input())
b = [int(input()) for x in range(a)]


num = 0
for j in range(100):
    count = 0
    for i in range(a):
        if b[i] % 2 == 0:
            count = 1 + count


    if count == a:
        b = [c/2 for c in b]
        num = 1 + num

print(num)

### FIXED CODE ###

n = int(input())
b = list(map(int, input().strip().split()))


num = 0
for j in range(100):
    count = 0
    for i in range(n):
        if b[i] % 2 == 0:
            count = 1 + count


    if count == n:
        b = [c/2 for c in b]
        num = 1 + num

print(num)
from numba import jit, f8, i8, b1, void

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


@jit(i8(i8[:]))
def solve(arr):
    INF = 1 << 40

    # dp初期化
    dp = [INF] * n
    dp[0] = 0

    for i in range(1, n):
        dp[i] = min(dp[j] + abs(arr[i] - arr[j])
                    for j in range(max(i - k, 0), i))

    return dp([n - 1])


print(solve(arr))

### FIXED CODE ###

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

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])
N = int(input())
a = list(map(int, input().split()))

def get_color(point):
    color = ''
    if 400 > point:
        color = 'grey'
    elif 800 > point:
        color = 'brown'
    elif 1200 > point:
        color = 'green'
    elif 1600 > point:
        color = 'light blue'
    elif 2000 > point:
        color = 'blue'
    elif 2400 > point:
        color = 'yellow'
    elif 2800 > point:
        color = 'orange'
    elif 3200 > point:
        color = 'red'
    else:
        color = 'free'
    return color
dict = {}
for i in range(N):
    color = get_color(a[i])
    if color not in dict.keys():
        dict[color] = 1
    else:
        dict[color] += 1

min_cnt = 0
max_cnt = 0
if 'free' not in dict.keys():
    min_cnt = max_cnt = len(dict.keys())
else:
    min_cnt = len(dict.keys())-1
    max_cnt = min(8, min_cnt + len(dict['free']))

print(min_cnt, max_cnt)


### FIXED CODE ###

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

def get_color(point):
    color = ''
    if 400 > point:
        color = 'grey'
    elif 800 > point:
        color = 'brown'
    elif 1200 > point:
        color = 'green'
    elif 1600 > point:
        color = 'light blue'
    elif 2000 > point:
        color = 'blue'
    elif 2400 > point:
        color = 'yellow'
    elif 2800 > point:
        color = 'orange'
    elif 3200 > point:
        color = 'red'
    else:
        color = 'free'
    return color
dict = {}
for i in range(N):
    color = get_color(a[i])
    if color not in dict.keys():
        dict[color] = 1
    else:
        dict[color] += 1

min_cnt = 0
max_cnt = 0
if 'free' not in dict.keys():
    min_cnt = max_cnt = len(dict.keys())
else:
    min_cnt = max(1, len(dict.keys())-1)
    max_cnt = len(dict.keys())-1 + dict['free']

print(min_cnt, max_cnt)
def main():
    N=int(input())
    A=list(map(int, input().split()))
    B=list(map(int, input().split()))

    count = 0
    while A!=B:
        b = True
        for i in range(N):
            d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
            if B[i] > d:
                b = False
                c = B[i] // d
                B[i] -= d * c
                count += c
        if b:
            print(-1)
            break
    else:
        print(count)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N=int(input())
    A=list(map(int, input().split()))
    B=list(map(int, input().split()))

    count = 0
    prev_count = -1
    while count!=prev_count:
        prev_count = count
        for i in range(N):
            d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
            c = (B[i]-A[i]) // d
            B[i] -= d * c
            count += c

    if A == B:
        print(count)
    else:
        print(-1)

if __name__ == '__main__':
    main()
v = str(inp).split()
dif_max = -200000

for i in range(len(v)):
    v[i] = int(v[i])

len = v[0]
for i in range(2, len + 1, 1):
    for j in range(i + 1, len + 1, 1):
        dif = v[j] - v[i]
        dif_max = dif if dif_max < dif else dif_max

print(dif_max)

### FIXED CODE ###

cnt = int(input())
dif_max = -1000000000
v_min = 1000000000

for i in range(cnt):
    buf = int(input())
    if i > 0:
        dif_max = dif_max if buf - v_min < dif_max else buf - v_min
    v_min = buf if buf < v_min else v_min
print(dif_max)
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append([i, a[i]])
b = sorted(b, key=lambda x: x[1])
c = []
for k, v in b:
    c.append(k+1)
print(' '.join(map(str, c))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append([i, a[i]])
b = sorted(b, key=lambda x: x[1])
c = []
for k, v in b:
    c.append(k+1)
print(' '.join(map(str, c)))
test =input()
cnt =0
for r in range(len(test)):
    s = int(test[r])
    if (s%2 == 1):
        cnt +=1

print(cnt)

### FIXED CODE ###

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

#2n
if (a%2==0):
    print('Even')    

elif(b%2==0):
    print('Even')

#2n-1    
else:
    print('Odd')
a = int(input())
b = int(input())

print(a*b)
print((a+b)*2)

### FIXED CODE ###

a,b = [int(i) for i in input().split()]
print(a*b,(a+b)*2)
import numpy as np

#initialization
nmatch = np.array([0,2,5,5,4,5,6,3,7,6])
N,M = map(int,input().split())
dp = [-1]*(N+1) # contains the number of digits it can make
dp[0] = 0
ff = np.array(list(map(int,input().split()))).reshape(-1,1)
fg = nmatch[ff].reshape(-1,1)
Atemp = np.concatenate([ff,fg],axis=1)
index0 = np.argsort(Atemp[:,0])
index1 = np.argsort(Atemp[:,1])
A = Atemp[index1] #sorted by the number of matches: ascending
B = Atemp[index0]
B = B[::-1] #sorted by the number: descending
for i in range(1,N+1):
    for k in range(M):
        j = A[k,1]
        i_old = i - j #available matches
        if (i-j) < 0:
            break
        if (i-j) == 0 and dp[i] == -1:
            dp[i] = 1
        if dp[i_old] != -1 and dp[i_old]+1 > dp[i]:
            dp[i] = dp[i_old] + 1
#print(dp)
ndigits = dp[N]
j = N
final_number = ''
for l in range(ndigits,0,-1):
    index = 0
    while True:
        temp_j = j - B[index,1]
        if temp_j < 0:
            index += 1
            continue
        if dp[temp_j] + 1 == dp[j]:
            final_number += str(B[index,0])
            j = temp_j
            break
        else:
            index += 1
        if index > M:
            break
print(int(final_number))


### FIXED CODE ###

a = input()
b = a.split()
A = int(b[0])
B = int(b[1])
if B%A == 0:
    print(A+B)
else:
    print(B-A)
s=input()
t=input()

ls=len(s)
lt=len(t)

dp=[[0]*(lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

ans=""
l=dp[ls][lt]-1
i=ls-1
j=lt-1
while l>=0:
    if s[i]==t[j]:
        ans=s[i]+ans
        i-=1
        j-=1
        l-=1
    else:
      	if dp[i-1][j]>dp[i][j-1]:
        	i-=1
    	else:
        	j-=1

print(ans)


### FIXED CODE ###

s=input()
t=input()
dp=[[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1

        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
    # print(dp[i])
ans=''
i,j=len(s),len(t)
while i > 0 and j > 0:
  if s[i-1]==t[j-1]:
    ans=s[i-1]+ans
    i=i-1
    j=j-1
  else:
    if dp[i-1][j]>dp[i][j-1]:
      i-=1
    else:
      j-=1
print(ans)
s = input()

counter = 0
moji = ""
for i in s:
  if i == "B":
	moji[:-1]
    continue
  else:
    moji+ i

### FIXED CODE ###

s = input()
 
counter = 0
moji = ""
for i in s:
	
	if i == "B":
		moji = moji[:-1]
		
		continue
    	

	moji = moji+ i

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

def shou(a):
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return -1
    return 1

f=0
for i in range(n):
    for j in range(n):
        tmp=a[i]
        a[i]=a[j]
        a[j]=tmp
        if shou(a)==1:
            f=1
        tmp=a[i]
        a[i]=a[j]
        a[j]=tmp
if f>0:
    print('YES')
else:
    print('NO')
    


### FIXED CODE ###

a,b=map(int,input().split())
if (a+b)%2==1:
    print("IMPOSSIBLE")
else:
    print((a+b)//2)
n = int(input())

ass = list(map(int,input().split()))

ans = 0
for i in range(60):
    k = 1 << i
    i_1 = sum([k & a for a in ass]) >> i
    ans += i_1 * (n - i_1) << i
    ans = ans % ((10**9) + 7)

print(ans)


### FIXED CODE ###

x,y,z = map(int,input().split())

if x + y + z > 21:
    print('bust')
else:
    print('win')
def solve(N,K,R,S,P,T):
    check = [0]*N
    ans = 0
    for i in range(N):
        if i < K or T[i] != T[i-K] or not check[i-K]:
            ans += P if T[i] == 'r' else R if T[i] == 's' else S
            check[i] = 1
    print(ans)

def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()
    solve()

if __name__ == "__main__":
    main()

### FIXED CODE ###

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
check = [0]*N
ans = 0
for i in range(N):
    if i < K or T[i] != T[i-K] or not check[i-K]:
        ans += P if T[i] == 'r' else R if T[i] == 's' else S
        check[i] = 1
print(ans)
a,b=int(input().split())
s=0
g=0
if a==1:
  s=300000
elif a==2:
  s=200000
elif a==3:
  s=100000
else:
  pass
if b==1:
  g=300000
elif b==2:
  g=200000
elif b==3:
  g=100000
else:
  pass
if a==1 and b==2:
  print(g+s+400000)
else:
  print(s+g)

### FIXED CODE ###

a,b=map(int,input().split())
s=0
g=0
if a==1:
  s=300000
elif a==2:
  s=200000
elif a==3:
  s=100000
else:
  s=0
if b==1:
  g=300000
elif b==2:
  g=200000
elif b==3:
  g=100000
else:
  g=0
if a==1 and b==1:
  print(g+s+400000)
else:
  print(s+g)
N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-(i)<M*M:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-((i)%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')
           
    
    

### FIXED CODE ###

N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
#print(c,a)
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-i<M*M:
    break
  if M>1 and i//N==N-1:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-((i)%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')
x=int(input())
for i in range(-1000,1000):
  for j in range(-1000,1000):
    if i**5-j**5==x:
      print(i,j)
      keep=1
      break
  if keep==1:
    break

### FIXED CODE ###

x=int(input())
keep=0
for i in range(-1000,1000):
  for j in range(-1000,1000):
    if i**5-j**5==x:
      print(i,j)
      keep=1
      break
  if keep==1:
    break
m=2019
l,r=map(int,input().split())

import numpy as np
s=set()
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=(ii*jj)%m
    if t==0:
      print(t)
      exit()
    if t<lr:
      lr=t
print(lr)

### FIXED CODE ###

m=2019
l,r=map(int,input().split())

if l==0 or l//m<r//m or l%m==0:
  print(0)
  exit()

import numpy as np
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=((ii%m)*(jj%m))%m
    if t==0:
        print(0)
        exit()
    if t<lr:
      lr=t
print(lr)
a=input()
if int(a/2)*2==a:
  print(a)
else:
  print(a*2)

### FIXED CODE ###

a=int(input())
b=int(a/2)
if b*2==a:
  print(a)
else:
  print(a*2)
import sys

for line in sys.stdin:
    s, w, h = map(float, line.strip().split(","))
    print(s if w / (h**2) >= 25)

### FIXED CODE ###

while True:
    try:
        s, w, h = map(float, input().split(','))
        if w / pow(h, 2) >= 25:
            print(int(s))
    except:
        break
import numpy as np

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

if N != 0:
    
    p_list = [int(n) for n in input().split()]
    
    X_near = np.array(list(range(int(np.ceil(X - N/2)), int(np.floor(X + N/2)) + 1)))
 
    remain_list = []
 
    for i in X_near:
        if i not in p_list:
            remain_list.append(i)
        

    remain_array = np.array(remain_list)
    min_bool = np.abs(X - remain_array).min() == np.abs(X - remain_array)
    print(remain_array[min_bool].min())
    
else:
    p_list = input()
    print(X)

### FIXED CODE ###

import numpy as np
 
X,N = map(int,input().split())
p = input()
 
if N != 0:
    
    p_list = [int(n) for n in p.split()]
    
    X_near = np.array(list(range(int(np.ceil(X - N/2 - 1)), int(np.floor(X + N/2)) + 2)))
 
    remain_list = []
 
    for i in X_near:
        if i not in p_list:
            remain_list.append(i)
        
 
    remain_array = np.array(remain_list)
    min_bool = np.abs(X - remain_array).min() == np.abs(X - remain_array)
    print(remain_array[min_bool].min())
    
if N == 0:
    print(X)
from sys import stdin
N = int(stdin.readline().rstrip())
A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
ans = 0 
for i in range(N):
    ans += len(set(A[i], B[i], C[i]))-1
print(ans)

### FIXED CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
ans = 0 
for i in range(N):
    ans += len(set([A[i], B[i], C[i]]))-1
print(ans)
def main(money):
  a  = money % 1000
  if a != 0:
    change = 1000 - a
  elif a = 0:
    change = 0
  print(change)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 20:25:04 2020

@author: KevinLU
"""
money = int(input())

a  = money % 1000
if a > 0:
    change = 1000 - a
else:
    change = 0
print(change)
X,Y,A,B,C = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

r.append(0)
for i in range(X,A):
    p[i] = 0
for i in range(Y,B):
    q[i] = 0

a = 0
b = 0
c = 0
cnt = 0

for i in range(X+Y):
    if (not a == X) and p[a] >= q[b] and p[a] >= r[c]:
        cnt += p[a]
        a += 1
    elif (not b == Y) and q[b] >= r[c]:
        cnt += q[b]
        b += 1
    else:
        cnt += r[c]
        c += 1
print(cnt)


### FIXED CODE ###

X,Y,A,B,C = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

p.append(0)
q.append(0)
r.append(0)
for i in range(X,A):
    p[i] = 0
for i in range(Y,B):
    q[i] = 0

a = 0
b = 0
c = 0
cnt = 0

for i in range(X+Y):
    if (not a == X) and p[a] >= q[b] and p[a] >= r[c]:
        cnt += p[a]
        a += 1
    elif (not b == Y) and q[b] >= r[c]:
        cnt += q[b]
        b += 1
    else:
        cnt += r[c]
        c += 1
print(cnt)