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

inf=998244353


N,K=map(int,input().split())
SS=[]

for i in range(K):
    s1,s2=map(int,input().split())
    for j in range(s1,s2+1):
        SS.append(j)

SS.sort()

table = [0 for k in range(N-1)] 

for s in SS:
    if s<=N-1:
        table[s-1]+=1
for i in range(N-1):
    if table[i]!=0:
        for s in SS:
            if i+s<N-1:
                table[i+s]+=table[i]
                table[i+s]%=inf
                #print(table,i,s)
            else:
                break
print(table[-1]%inf)


### FIXED CODE ###

inf=998244353


N,K=map(int,input().split())
SS=[list(map(int,input().split())) for i in range(K)]

SS.sort()

table = [0 for k in range(N)] 
diff = [0 for k in range(N-1)]

table[0]=1
diff[0]=-1

for i in range(N-1):
    if table[i]!=0:
        for s in SS:
            lef=s[0]
            rig=s[1]
            if i+lef-1<N-1:
                diff[i+lef-1]+=table[i]
            if i+rig<N-1:
                diff[i+rig]-=table[i]
    table[i+1]=table[i]+diff[i]
    table[i+1]%=inf

print(table[N-1])
### BUGGY CODE ###

import sys
input=sys.stdin.readline
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  a=9999999999999
  for j in range(1,min(k+1,i+1)):
    a=min(a,dp[i-j]+abs(h[i-j]-h[i]))
  dp[i]=a
print(dp[-1])

### FIXED CODE ###

import sys
input=sys.stdin.readline
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  kk=max(i-k,0)
  dp[i]=min(d+abs(hh-h[i])for d,hh in zip(dp[kk:i],h[kk:i]))
print(dp[n-1])
### BUGGY CODE ###

import heapq

def resolve():
    H,W = map(int,input().split())
    Sy,Sx = [int(i)-1 for i in input().split()]
    Gy,Gx = [int(i)-1 for i in input().split()]

    MP = [input() for i in range(H)]
    q =[]
    mxxx = 10**10
    score=[[mxxx]*W  for i in range(H)]
    score[Sy][Sx] = 0
    heapq.heappush(q,(0,Sx,Sy))
    visited = [[False for j in range(W)] for i in range(H)]

    while q:
        cs,x,y = heapq.heappop(q) 

        if visited[y][x]:
            continue
        visited[y][x]=True


        if y!=0 and MP[y-1][x]=='.' and score[y][x]<score[y-1][x]:

            score[y-1][x]=score[y][x]
            heapq.heappush(q,(cs,x,y-1))
        if y!=H-1 and MP[y+1][x]=='.' and score[y][x]<score[y+1][x]:


            score[y+1][x]=score[y][x]
            heapq.heappush(q,(cs,x,y+1))
  
        if x!=0 and MP[y][x-1]=='.' and score[y][x]<score[y][x-1]:

            score[y][x-1]=score[y][x]
            heapq.heappush(q,(cs,x-1,y))
        if x!=W-1 and MP[y][x+1]=='.' and score[y][x]<score[y][x+1]:

            score[y][x+1]=score[y][x]
            heapq.heappush(q,(cs,x+1,y))


        for i in range(max(0,y-2),min(H,y+3)):
            for j in range(max(0,x-2),min(W,x+3)):

                if MP[i][j]=='#':
                    continue
                if score[i][j]>score[y][x]+1:
                    score[i][j]=score[y][x]+1
                    heapq.heappush(q,(cs+1,j,i))

    if score[Gy][Gx]==mxxx:
        print(-1)
    else:
        print(score[Gy][Gx])
    
resolve()


### FIXED CODE ###

from collections import deque

def resolve():
    H,W = map(int,input().split())
    Sy,Sx = [int(i)-1 for i in input().split()]
    Gy,Gx = [int(i)-1 for i in input().split()]

    MP = [input() for i in range(H)]
    q =[]
    mxxx = 10**10
    score=[[mxxx]*W  for i in range(H)]
    score[Sy][Sx] = 0
    deq = deque()
    deq.append((Sy,Sx))
    unvisited=set()
    for y,row in enumerate(MP):
        for x,i in enumerate(row):
            if i ==".":
                unvisited.add((y,x))

    while deq:
        y,x = deq.popleft()
        if not (y,x) in unvisited:
            continue
        unvisited.remove((y,x))

        if (y-1,x) in unvisited and score[y-1][x]>score[y][x]:
            score[y-1][x]=score[y][x]
            deq.appendleft((y-1,x))
        if (y+1,x) in unvisited and score[y+1][x]>score[y][x]:
            score[y+1][x]=score[y][x]
            deq.appendleft((y+1,x))
        if (y,x-1) in unvisited and score[y][x-1]>score[y][x]:
            score[y][x-1]=score[y][x]
            deq.appendleft((y,x-1))
        if (y,x+1) in unvisited and score[y][x+1]>score[y][x]:
            score[y][x+1]=score[y][x]
            deq.appendleft((y,x+1))

        for i in range(y-2,y+3):
            for j in range(x-2,x+3):
                if (i,j) in unvisited and score[i][j] > score[y][x]+1:
                    score[i][j] = score[y][x]+1
                    deq.append((i,j))
    
    if score[Gy][Gx] == 10**10:
        print(-1)
    else:
        print(score[Gy][Gx])




    
resolve()
### BUGGY CODE ###

import numpy as np
size = int(input())
A = np.array(list(map(int,input().split())))
i = np.array(list(range(1,size+1)))

remain_list = A-i
while(True):
    zero_count  = np.sum(remain_list==0)
    minus_count = np.sum(remain_list <0)
    plus_count  = np.sum(remain_list >0)

    if zero_count == max(zero_count,minus_count,plus_count) or plus_count == minus_count:
        break

    if plus_count == max(zero_count,minus_count,plus_count):
        remain_list = remain_list - 1

    if minus_count == max(zero_count,minus_count,plus_count):
        remain_list = remain_list + 1

print(np.sum(np.abs(remain_list)))


### FIXED CODE ###

import math
import statistics
import numpy as np
size = int(input())
A = np.array(list(map(int,input().split())))
i = np.array(list(range(1,size+1)))

remain_list = A-i
median = statistics.median(remain_list)
print(int(sum(abs(remain_list - median))))
### BUGGY CODE ###

import numpy as np
n,m,q=map(int,input().split())
s=[[] for i in range(n+1)]
t=[]
ss=[]
for i in range(m):
    x,y=map(int,input().split())
    s[x]+=[y]

for i in range(q):
    x,y=map(int,input().split())
    ss=s[x:]
    ww=[]
    for j in range(n-x+1):
        ww+=ss[j]
    ww=np.array(ww)
    print(len(ww[ww<=y]))


### FIXED CODE ###

from itertools import accumulate
n,m,q=map(int,input().split())
s=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    s[n-x][y-1]+=1
def f(s):
    for i in range(len(s)):
        s[i]=list(accumulate(s[i]))
f(s)
s=list(zip(*s))
f(s)
for i in range(q):
    x,y=map(int,input().split())
    print(s[y-1][n-x])
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
B = []
for i in range(N):
  if A.count(A[i]) != 1:
    continue
  else:
    p = 0
    for j in B:
      if A[i] % j == 0:
        p = 1
    if p == 0:
      B.append(A[i])
      
print(len(B))

### FIXED CODE ###

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

As.sort()
# print(As)

all_nums = [0] * (As[-1] + 1)

for A in As:
    all_nums[A] += 1
#print(all_nums)
dup = 0

for i, num in enumerate(all_nums):
    if num == 0: #その数が一つもないなら無視
        continue
    if num > 1: #同じ数が複数ある場合はあとで除くためにカウント
        dup += num
    j = 2
    while i * j <= As[-1]:
        all_nums[i*j] = 0
        j += 1
    #print(all_nums)

print(sum(all_nums)-dup)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
tmp = 1
for i in range(k):
    tmp *= a[i]

for i in range(k, n):
    tmp1 = tmp
    tmp1 *= a[i]
    tmp1 //= a[i-k]
    if tmp < tmp1:
        print('Yes')
    else:
        print('No')
    tmp = tmp1


### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    C = Counter(A)

    ans = 0
    if len(C) <= K:
        print(0)
        return
    else:
        for i in range(len(C) - K):
            ans += C.most_common()[-i - 1][1]

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    C = Counter(A)

    ans = 0
    if len(C) <= K:
        print(0)
        return
    else:
        mc = C.most_common()
        for i in range(len(C) - K):
            ans += mc[-i - 1][1]

    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import collections

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

ans = [0] * (N + 1)
depth = [0] * (N + 1)
parent = [[] for i in range(N+1)]
child = [[] for i in range(N+1)]
deq = collections.deque()

for i in range(N+M-1):
    p, c = map(int, input().split())
    parent[c].append(p)
    child[p].append(c)
for i in range(1, N+M-1):
    if len(parent[i]) == 0:
        deq.append(i)
        break
while len(deq) > 0:
    v = deq.pop()
    if len(child[v]) > 0:
        for u in child[v]:
            deq.appendleft(u)
            ans[u] = v
for i in range(1,N+1):
    print(ans[i])

### FIXED CODE ###

import collections

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

ans = [0] * (N + 1)
parent = [0] * (N + 1)
parent[0] = N+M
child = [[] for i in range(N+1)]
deq = collections.deque()

for i in range(N+M-1):
    p, c = map(int, input().split())
    parent[c] += 1
    child[p].append(c)
root = parent.index(min(parent))
deq.append(root)
while len(deq) > 0:
    v = deq.pop()
    if len(child[v]) > 0:
        for u in child[v]:
            if parent[u] == 1:
                deq.appendleft(u)
                ans[u] = v
            else:
                parent[u] -= 1
for i in range(1,N+1):
    print(ans[i])
### BUGGY CODE ###

x,y,z,k=map(int,input().split())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
cl=[int(i) for i in input().split()]
lst=[]
for i in al:
  for j in bl:
    lst.append(i+j)
lst.sort(reverse=True)
num=min(x*y,k)
lst=lst[:k]
L=[]
for i in cl:
  for j in lst:
    L.append(i+j)
L.sort(reverse=True)
for i in range(k):
  print(L[i])

### FIXED CODE ###

x,y,z,k=map(int,input().split())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
cl=[int(i) for i in input().split()]
lst=[i+j for i in al for j in bl]
lst.sort(reverse=True)
num=min(x*y,k)
lst=lst[:num]
L=[i+j for i in cl for j in lst]
L.sort(reverse=True)
for i in range(k):
  print(L[i])
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
P = []
for i in range(len(A)):
  if (A[i] not in P):
    P.append(A[i])
c = 0
for i in range(len(P)):
  if (A.count(P[i])%2 == 1):
    c += 1
print(c)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
j = 1
J = 1
ans = 0
for j in range(1,len(A)):
  if (A[j-1] == A[j]):
    J += 1
  else:
    if (J%2 != 0):
      ans += 1
      J = 1
    else:
      J = 1
if (J%2 != 0):
  ans += 1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from collections import deque
H, W = list(map(int, input().split()))
Sn = [input() for _ in range(H)]

def func(h,w): # 黒のみ
    map = [[0 for _ in range(W)] for _ in range(H)]
    que = deque()
    que.append((h,w))
    while len(que) > 0:
        xh,xw = que.popleft()
        if map[xh][xw] == 0:
            map[xh][xw] = Sn[xh][xw]
        else:
            continue
        # 左
        if xw - 1 >= 0:
            if Sn[xh][xw] != Sn[xh][xw-1] and map[xh][xw-1] == 0:
                que.append((xh, xw-1))
        # 上
        if xh - 1 >= 0:
            if Sn[xh][xw] != Sn[xh-1][xw] and map[xh-1][xw] == 0:
                que.append((xh-1, xw))
        # 右
        if xw + 1 < W:
            if Sn[xh][xw] != Sn[xh][xw+1] and map[xh][xw+1] == 0:
                que.append((xh, xw+1))
        # 下
        if xh + 1 < H:
            if Sn[xh][xw] != Sn[xh+1][xw] and map[xh+1][xw] == 0:
                que.append((xh+1, xw))

    return map
    # cnt = 0
    # for i in range(H):
    #     for j in range(W):
    #         if map[i][j] == ".":
    #             cnt += 1
    # return cnt

cnt = 0
visited = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if Sn[i][j] == "#" and visited[i][j]==0:
            ret = func(i,j)
            b_cnt = 0
            w_cnt = 0
            for i2 in range(H):
                for j2 in range(W):
                    if ret[i2][j2] == "#":
                        b_cnt += 1
                        visited[i2][j2] = 1
                    elif ret[i2][j2] == ".":
                        w_cnt += 1
                        visited[i2][j2] = 1

            cnt += b_cnt*w_cnt
            
print(cnt)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque
H, W = list(map(int, input().split()))
Sn = [input() for _ in range(H)]

def func(h,w): # 黒のみ
    move = [(0,-1),(-1,0),(0,1),(1,0)]
    w_cnt = 0
    b_cnt = 0
    que = deque()
    que.append((h,w))
    while len(que) > 0:
        xh,xw = que.popleft()
        if visited[xh][xw] == 0:
            visited[xh][xw] = 1
            if Sn[xh][xw] == "#":
                b_cnt += 1
            else:
                w_cnt += 1
        else:
            continue
            
        for mh, mw in move:
            if 0 <= xh + mh < H and 0 <= xw + mw < W:
                if Sn[xh][xw] != Sn[xh + mh][xw + mw] and visited[xh + mh][xw + mw] == 0:
                    que.append((xh + mh, xw + mw))

    return b_cnt, w_cnt

cnt = 0
visited = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if Sn[i][j] == "#" and visited[i][j]==0:
            b_cnt, w_cnt = func(i, j)
            cnt += b_cnt*w_cnt
            
print(cnt)
### BUGGY CODE ###

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

su=[]
for i in s:
    shu=sorted(list(i))
    su.append("".join(shu))


count=0
while len(su)>0:
  j=su[0]
  del su[0]
  c=su.count(j)
  if c!=0:
    count+=int(c*(c+1)/2)
    for i in range(c):
      su.remove(j)
      
print(count)

### FIXED CODE ###

import collections
N=int(input())
su=["".join(sorted(list(input()))) for _ in range(N)]

C=list(collections.Counter(su).values())

ans=0
for i in C:
  if i>1:
    ans+=i*(i-1)//2

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

import collections
#n = int(input())
n, m = list(map(int, input().split()))
#b = list(map(int, input().split()))
count =[0]*n

for i in range(m):
    x,y = [int(j) for j in input().split()]
    for j in range(x-1, y):
        count[j]+=1

print(count.count(m))



### FIXED CODE ###

n, m = list(map(int, input().split()))
#b = list(map(int, input().split()))
l = []
r = []
for i in range(m):
    x, y = list(map(int, input().split()))
    l.append(x)
    r.append(y)
L = l[0]
R = r[0]
# print("--------")
for i in range(1, m):
    if not((R < l[i] and R < r[i]) or (r[i] < L and l[i] < L)):
        L = max(L, l[i])
        R = min(R, r[i])
    else:
        print(0)
        exit()
    #print(L, R)

print(R-L+1)
### BUGGY CODE ###

N, M = [int(x) for x in input().split()]

A = [[] for i in range(M)]

for i in range(N):
	t1, t2 = [int(x) for x in input().split()]
	if t1-1 <= M-1:
		A[t1-1].append(t2)


ans = 0
for i in range(M):
	t = 0
	idx = -1
	for j in range(i+1):
		if A[j] != []:
			if max(A[j]) >= t:
				idx = j
				t = max(A[j])
	if idx!=-1:
		ans += t
		A[idx].remove(t)


print(ans)



### FIXED CODE ###

import heapq

N,M=map(int,input().split())
d={}
for i in range(M):d[i]=[0]
for i in range(N):
    a,b=map(int,input().split())
    if 0<=M-a:
        d[M-a].append(b)

hq=[]
ans=0
for i in range(M)[::-1]:
    [heapq.heappush(hq,-j) for j in d[i]]
    ans-=heapq.heappop(hq)
print(ans)
### BUGGY CODE ###

from statistics import median
q0=int(input())
ind2=0
ind1=0
a=[]
b=[]
for iii in range(q0):
  q=[int(_) for _ in input().split()]
  lenq=len(q)
  if lenq==1:
    a.sort()
    la=len(a)-1
    ind1=a[la//2]
    ind2=sum([abs(_a-ind1) for _a in a])+sum(b)
    print(ind1,ind2)
  elif lenq==3:
    a.append(q[1])
    b.append(q[2])

### FIXED CODE ###

import heapq as h
q_num=int(input())
bsum=0
high=[]
low=[]
asum=0
for iii in range(q_num):
  q=[int(_) for _ in input().split()]
  if q[0]==1:
    bsum+=q[2]
    if len(low)==0:
      h.heappush(low,-q[1])
    else:
      asum+=abs(q[1]+low[0])
      if -low[0]>=q[1]:
        h.heappush(low,-q[1])
      else:
        h.heappush(high,q[1])
      
    if len(low)>=len(high)+2:
      ltoh=h.heappop(low)
      h.heappush(high, -ltoh)
    elif len(high)>=len(low)+1:
      ltoh=h.heappop(high)
      asum+=-low[0]-ltoh
      h.heappush(low, -ltoh)
  else:
    print(-low[0],asum+bsum)
### BUGGY CODE ###

N,M = map(int,input().split())
A = sorted([int(x) for x in input().split()])

for i in range(M):
    B,C = map(int,input().split())
    
    if A[-1] <= C:  j,m = B,N
    elif A[0] >= C: j,m = 0,0
    else:
        m,s,e = N//2, 0, N
        while A[m] > C or C > A[m+1]:
            if A[m] > C:    e = m
            elif C > A[m+1]:    s = m+1
            m = (s+e)//2
        
        if B < m:   j = B
        else:   j = m 

    A = A[j:m+1] + [C]*j + A[m+1:N]

print(sum(A))
    

### FIXED CODE ###

import numpy as np

N,M = map(int,input().split())
A = sorted([int(x) for x in input().split()])
An = 0
C = []

for i in range(M):
    C += [[int(x) for x in input().split()]]
    
C = sorted(C,key=lambda x: x[1])[::-1]

m = 0
for i in range(M):
    b = C[i][0]
    if m == N:
        break
    if m+b >= N:
        b = N-m

    if A[m + b - 1] < C[i][1]:
        m = m + b
        An += C[i][1]*b
    else:
        c = C[i][1]
        for j in range(2,b):
            if A[m+b-j] < c:
                m = m + b - j + 1
                An += c*(b-j+1)
                break
        break

if m == N:  print(An)
else:   print(sum(A[m:]) + An)
### BUGGY CODE ###

n, q = [int(el) for el in input().split(' ')]
data = [0] * n
ex_result = 0
for _ in range(q):
    a, v = [int(el) for el in input().split(' ')]
    data[a-1] += v
    result = max(data)
    print(data.index(result)+1, result)

### FIXED CODE ###

n, q = [int(el) for el in input().split(' ')]
data = [0] * n
result, index = 0, 1
for _ in range(q):
    a, v = [int(el) for el in input().split(' ')]
    data[a-1] += v
    if v > 0:
        if result < data[a-1]:
            result, index = data[a-1], a
        elif result == data[a-1]:
            index = min(index, a)
    else:
        if index == a:
            result = max(data)
            index = data.index(result) + 1
    print(index, result)
### BUGGY CODE ###

import sys
from collections import deque
input=sys.stdin.readline
h,w=map(int,input().split())
cx,cy=map(int,input().split())
cx+=1
cy+=1
dx,dy=map(int,input().split())
dx+=1
dy+=1
l=[]
l.append("#"*(w+4))
l.append("#"*(w+4))
for i in range(h):
    l.append("##"+input()[:-1]+"##")
l.append("#"*(w+4))
l.append("#"*(w+4))
#input

"""
for i in l:
    print(*i)
"""

q=deque([[cx,cy]])
qq=deque([[cx,cy]])
s=[[-1 for i in j]for j in l]
s[cx][cy]=0

while len(qq)>0:
    while len(q)>0:
        x,y=q.popleft()
        for px,py in ((0,1),(0,-1),(1,0),(-1,0)):
            if l[x+px][py+y]=="." and s[x+px][y+py]==-1:
                s[x+px][y+py]=s[x][y]
                q.appendleft([x+px,y+py])
                qq.append([x+px,y+py])
    x,y=qq.popleft()
    for px in range(-2,3):
        for py in range(-2,3):
            if l[x+px][py+y]=="." and s[x+px][y+py]==-1:
                s[x+px][y+py]=s[x][y]+1
                q.append([x+px,y+py])
                qq.append([x+px,y+py])
"""
for i in s:
    print(*i)
"""

print(s[dx][dy])

### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
cx,cy=map(int,input().split())
cx+=1
cy+=1
dx,dy=map(int,input().split())
dx+=1
dy+=1
l=[]
l.append("#"*(w+4))
l.append("#"*(w+4))
for i in range(h):
    l.append("##"+input()+"##")
l.append("#"*(w+4))
l.append("#"*(w+4))
#input

"""
for i in l:
    print(*i)
"""

q=deque([[cx,cy]])
qq=deque([[cx,cy]])
s=[[-1 for i in j]for j in l]
s[cx][cy]=0

while len(qq)>0:
    while len(q)>0:
        x,y=q.popleft()
        for px,py in ((0,1),(0,-1),(1,0),(-1,0)):
            if l[x+px][py+y]=="." and s[x+px][y+py]==-1:
                s[x+px][y+py]=s[x][y]
                q.appendleft([x+px,y+py])
                qq.append([x+px,y+py])
    x,y=qq.popleft()
    for px in range(-2,3):
        for py in range(-2,3):
            if l[x+px][py+y]=="." and s[x+px][y+py]==-1:
                s[x+px][y+py]=s[x][y]+1
                q.append([x+px,y+py])
                qq.append([x+px,y+py])
"""
for i in s:
    print(*i)
"""

print(s[dx][dy])
### BUGGY CODE ###

# coding: utf-8
import numpy as np
X,Y,A,B,C = list(map(int, input().split()))
P = np.sort(np.array(list(map(int, input().split()))))
Q = np.sort(np.array(list(map(int, input().split()))))
R = np.sort(np.array(list(map(int, input().split()))))

label = np.array([1] * Q.shape[0] + [0] * R.shape[0])
QR = np.concatenate([Q,R])
QR = np.concatenate([label.reshape(1,-1), QR.reshape(1,-1)], axis=0)
QR = QR[:,np.argsort(QR[1,:])]

points = []
for k in range(0,X+1):
  if QR[0,:][-(X+Y-k):].sum() > Y:
    if X-k > C:
      points.append(0)
    else:
      if k == 0:
        score = Q[-Y:].sum()+R[-(X-k):].sum()
      else:
        score = Q[-Y:].sum()+R[-(X-k):].sum() + P[-k:].sum()
      points.append(score)

  else:
    if QR.shape[1] < X+Y-k:
      points.append(0)
    else:
      if k == 0:
        score = QR[1,-(X+Y-k):].sum()
      else:
        score = QR[1,-(X+Y-k):].sum() + P[-k:].sum()
      points.append(score)
print(max(points))

### FIXED CODE ###

# coding: utf-8
X,Y,A,B,C = list(map(int, input().split()))
P = sorted(list(map(int, input().split())))[-X:]
Q = sorted(list(map(int, input().split())))[-Y:]
R = list(map(int, input().split()))

total = sorted(P + Q + R)[-X-Y:]
print(sum(total))
### BUGGY CODE ###

N, W = list(map(int, input().split(" ")))

l = []
for i in range(N):
	w, v = list(map(int, input().split(" ")))
	l.append((w, v))
dp =  [[0] * (W+1) for _ in range(N+1)]

for i in range(0, N):
	for w in range(1, W+1):
		weight = l[i-1][0]
		value = l[i-1][1]
		if w >= weight:
			dp[i + 1][w] = max([dp[i][w - weight] + value, dp[i][w]])
		else:
			dp[i + 1][w] = dp[i][w]
print(dp[N][W])


### FIXED CODE ###

N, W = list(map(int, input().split(" ")))
dp =  [[0] * (W+1) for _ in range(N+1)]
 
for i in range(0, N):
	weight, value = map(int, input().split(" "))
	for w in range(1, W+1):
		if w >= weight:
			dp[i + 1][w] = max([dp[i][w - weight] + value, dp[i][w]])
		else:
			dp[i + 1][w] = dp[i][w]
print(dp[N][W])
### BUGGY CODE ###

N = int(input())
list = []
for i in range(N):
    number = int(input())
    if number in list:
        list.remove(number)
        #print(list)
    else:
        list.append(number)
        #print(list)
print(len(list))


### FIXED CODE ###

N = int(input())
Result = set()
for i in range(N):
    number = int(input())
    if  number in Result:
        Result.remove(number)
    else:
        Result.add(number)
print(len(Result))