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

x, y, a, b, c = map(int, input().split())
pn = list(map(int, input().split()))
qn = list(map(int, input().split()))
rn = list(map(int, input().split()))

pn.sort(reverse=True)
qn.sort(reverse=True)
rn.sort(reverse=True)

pn = pn[:x]
qn = qn[:y]

while min(pn[-1], qn[-1]) <= rn[0]:
  if pn[-1] >= qn[-1]:
    qn.insert(0,rn[0])
    del qn[-1]
  else:
    pn.insert(0,rn[0])
    del pn[-1]
  del rn[0]
  if len(rn) == 0:
    break
  
print(sum(pn) + sum(qn))


### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
pn = list(map(int, input().split()))
qn = list(map(int, input().split()))
rn = list(map(int, input().split()))

pn.sort(reverse=True)
qn.sort(reverse=True)

pqr = pn[:x] + qn[:y] + rn
pqr.sort(reverse=True)
  
print(sum(pqr[:x+y]))
### BUGGY CODE ###

N = int(input())

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

ans = 1

for item in A:
    ans *= item

if ans > 10**18:
    print(-1)
    exit()

print(ans)

### FIXED CODE ###

N = int(input())

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

ans = 1

for item in A:
    ans *= item

    ans = min(ans, 10**18 + 1)

if ans == 10**18 + 1:
    print(-1)
    exit()

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

N=int(input())
a=[0]*(N+2)
c=0
for i in range (N):
    S=input()
    d=0
    for j in range (N):
        #print(j,S,a[j])
        if a[j]!=S:
            d=0
        else:
            a[j]=S
            d=1
            break
    if d==0:
        a[c]=S
        c+=1
print(c)


### FIXED CODE ###

N=int(input())
a=[0]*(N)
c=0
for i in range (N):
    S=input()
    a[i]=S
c=len(set(a))
print(c)
### BUGGY CODE ###

s = input()
q = int(input())

reverse = 0

for i in range(q):
    inp = input()
    if len(inp) <= 1:
        reverse += 1
    else:
        dmy, f, c = inp.split()
        f = int(f)
        if reverse & 1:
            if f == 1:
                s = s + c
            else:
                s = c + s
        else:
            if f == 1:
                s = c + s
            else:
                s = s + c

if reverse & 1:
    print(s[::-1])
else:
    print(s)



### FIXED CODE ###

s = input()
q = int(input())

reverse = 0
sento = ''
matsubi = ''

for i in range(q):
    inp = input()
    if len(inp) <= 1:
        reverse += 1
    else:
        dmy, f, c = inp.split()
        f = int(f)
        if reverse & 1:
            if f == 1:
                matsubi = matsubi + c
            else:
                sento = c + sento
        else:
            if f == 1:
                sento = c + sento
            else:
                matsubi = matsubi + c

s = sento + s + matsubi

if reverse & 1:
    print(s[::-1])
else:
    print(s)
### BUGGY CODE ###

import itertools
##print(ord("A"))
n = int(input())
#n,k = map(int,input().split())
h = list(map(int,input().split()))	
ans = []

for i in range(1,n+1):
    #print(i)
    for j in range(n):
        
        if h[j] == i:
            ans.append(j+1)
#print(ans)
for i in range(len(ans)):
    print(ans[i],end=" ")



### FIXED CODE ###

import itertools
##print(ord("A"))
n = int(input())
#n,k = map(int,input().split())
h = list(map(int,input().split()))	
ans = [0]*n
for i in range(n):
    ans[h[i]-1]= i+1
#print(ans)
for i in range(n):
    print(ans[i],end=" ")
"""
for i in range(1,n+1):
    #print(i)
    for j in range(n):
        
        if h[j] == i:
            ans.append(j+1)
#print(ans)
for i in range(len(ans)):
    print(ans[i],end=" ")
"""
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
x=[]
for i in range(m):
    b,c=map(int,input().split())
    x.append([b,c])
y=sorted(x,key=lambda x:(x[1],x[0]),reverse=True)

d=[]
for i in range(m):
    d.extend([y[i][1]]*y[i][0])

for i in range(n):
    if len(d)<=i:
        break
    if d[i]>a[i]:
        a[i]=d[i]
    else:
        break
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
x=[]
for i in range(m):
    b,c=map(int,input().split())
    x.append([b,c])
y=sorted(x,key=lambda x:(x[1],x[0]),reverse=True)

p=0
q=0
for i in range(n):
    if a[i]<y[p][1]:
        a[i]=y[p][1]
        q+=1
    else:
        break
    if q==y[p][0]:
        p+=1
        q=0
        if p==m:
            break

print(sum(a))
### BUGGY CODE ###

import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
  N, M = read_int_list()
  A = [0] * M
  B = [0] * M
  for i in range(M):
    A[i], B[i] = read_int_list()

  res = [0] * (N - 1)
  done = set()
  l = set([1])
  for i in range(N):
    l2 = set()
    for k in range(M):
      for t in l:
        if t == A[k]:
          if B[k] not in l and B[k] not in done:
            l2.add(B[k]) 
            res[B[k] - 2] = A[k]

        if t == B[k]:
          if A[k] not in l and A[k] not in done:
            l2.add(A[k])
            res[A[k] - 2] = B[k]

    # done = done.union(set(l))
    done.update(l)
    l = l2

  return res


def main():
    res = solve()
    print('Yes', *res, sep='\n')


main()


### FIXED CODE ###

import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
  N, M = read_int_list()
  A = [0] * M
  B = [0] * M
  v = [set() for i in range(N)] 
  for i in range(M):
    A[i], B[i] = read_int_list()
    v[A[i] - 1].add(B[i])
    v[B[i] - 1].add(A[i])

  res = [0] * (N - 1)
  done = set()
  l = set([1])
  for i in range(N):
    l2 = set()
    for t in l:
      for r in v[t - 1]:
        if r not in l and r not in done:
          l2.add(r) 
          res[r - 2] = t

    # done = done.union(set(l))
    done.update(l)
    l = l2

  return res


def solve0():
  N, M = read_int_list()
  A = [0] * M
  B = [0] * M
  v = [set()] * N
  for i in range(M):
    A[i], B[i] = read_int_list()
    v[A[i] - 1].add(B[i])
    v[A[i] - 1].add(B[i])

  res = [0] * (N - 1)
  done = set()
  l = set([1])
  for i in range(N):
    l2 = set()
    for k in range(M):
      for t in l:
        if t == A[k]:
          if B[k] not in l and B[k] not in done:
            l2.add(B[k]) 
            res[B[k] - 2] = A[k]

        if t == B[k]:
          if A[k] not in l and A[k] not in done:
            l2.add(A[k])
            res[A[k] - 2] = B[k]

    # done = done.union(set(l))
    done.update(l)
    l = l2

  return res


def main():
    res = solve()
    print('Yes', *res, sep='\n')


main()
### BUGGY CODE ###

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

A.sort()

def discount(A,M,N):
    cost=0
    for i in range(len(A)):
        cost+=A[i]
    while M>0:
        cost=cost-A[N-1]+A[N-1]//2
        M-=1
        A[N-1]//=2
        A.sort()
    return cost

print(discount(A,M,N))

### FIXED CODE ###

import heapq

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

cost=[]
heapq.heapify(cost)

for i in range(N):
    heapq.heappush(cost,-A[i])

min_cost=sum(A)

while M>0:
    max_cost=(-1)*heapq.heappop(cost)
    cut_cost=max_cost-max_cost//2
    min_cost-=cut_cost
    max_cost-=cut_cost
    heapq.heappush(cost,(-1)*max_cost)
    M-=1

print(min_cost)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))
L = [0] + list(accumulate(A))
dp = [[-1]*(n+1) for i in range(n+1)]
def dfs(i, j):
  if dp[i][j] != -1:
    return dp[i][j]
  if i == j:
    dp[i][j] = 0
    return 0
  res = max(A[i] + L[j] - L[i+1] - dfs(i+1, j), A[j-1] + L[j-1] - L[i] - dfs(i, j-1))
  dp[i][j] = res
  return res
dfs(0, n)
ans = 2*dp[0][n] - L[n]
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))
L = [0] + list(accumulate(A))
dp = [[0]*(n+1) for i in range(n+1)]
for d in range(1, n+1):
  for i in range(n+1-d):
    dp[i][i+d] = max(A[i] + L[i+d] - L[i+1] - dp[i+1][i+d], A[i+d-1] + L[i+d-1] - L[i] - dp[i][i+d-1])
ans = 2*dp[0][n] - L[n]
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
import collections
table=collections.defaultdict(list)
for i in range(M):
  a,b=map(int,input().split())
  table[a].append(b)
  table[b].append(a)
for x in table[1]:
  if x in table[N]:
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
    

### FIXED CODE ###

N,M=map(int,input().split())
import collections
table=collections.defaultdict(int)
table2=collections.defaultdict(int)
for i in range(M):
  a,b=map(int,input().split())
  if a==1:
    table[b]+=1
  if b==N:
    table2[a]+=1
for x in table:
  if x in table2:
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
### BUGGY CODE ###

import bisect


class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える"""
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


def compress(array):
    """座標圧縮したリストを返す"""
    array2 = sorted(set(array))
    memo = {value: index for index, value in enumerate(array2)}
    return memo

n, d, a = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

info = sorted(info)
b = [info[i][0] for i in range(n)]
memo = compress([info[i][0] for i in range(n)])
bit = BIT(n)

for i in range(n):
    ind, val = info[i]
    bit.add(memo[ind], memo[ind] + 1, val)

ans = 0
for i in range(n):
    tmp = bit.get_val(i)
    if tmp <= 0:
        continue
    ans += -((-tmp) // a)
    ind, _ = info[i]
    nxt_ind = ind + 2 * d
    ii = bisect.bisect_right(b, nxt_ind)
    bit.add(i, ii, ((-tmp) // a) * a)
print(ans)

### FIXED CODE ###

class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    get_val: i番目の値を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


from operator import itemgetter
n, d, a = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

info = sorted(info, key = itemgetter(0))
bit = BIT(n)

for i in range(n):
    bit.add(i, i+1, info[i][1])

info.append([10**18, 0])
ans = 0 
r = 0
for i in range(n):
    num = bit.get_val(i)
    if num <= 0:
        continue
    while True:
        if info[r][0] - info[i][0] > 2*d:
            break
        else:
            r += 1
    ans += -((-num) // a)
    bit.add(i, r, -(-((-num) // a)) * a)
print(ans)
### BUGGY CODE ###

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

# 方針：r, g, bのすべての組み合わせから、j-i=k-jを引く

r, g, b = 0, 0, 0
for c in S:
  if c == "R": r += 1
  if c == "G": g += 1
  if c == "B": b += 1

total = r*g*b

for i in range(len(S)):
  for j in range(i+1, len(S)):
    if S[i] == S[j]: continue

    k = 2*j - i
    if k >= N: continue
    if len(set((S[i], S[k], S[j]))) == 3:
      total -= 1

print(total)

### FIXED CODE ###

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

r, g, b = 0, 0, 0
for c in S:
  if c == "R": r += 1
  if c == "G": g += 1
  if c == "B": b += 1

total = r*g*b

for i in range(N):
  for j in range(i+1, N):
    if S[i] == S[j]: continue

    k = 2*j - i
    if k >= N: continue
    if S[i] == S[k] or S[j] == S[k]: continue
    total -= 1

print(total)
### BUGGY CODE ###

from operator import itemgetter

A, B, C, D, E, F = list(map(int,input().split()))
X = []
ans = 1000
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                if 100*A*i+100*B*j+C*k+D*l != 0:
                    if 100*A*i+100*B*j+C*k+D*l <= F and (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l) <= E/(100 + E):
                        ans =(E/(100 + E) - (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l))
                        X.append([ans , 100*A*i+100*B*j+C*k+D*l, C*k+D*l])
X = sorted(X,key=itemgetter(0),reverse = False) 

print(X[0][1],X[0][2])

### FIXED CODE ###

from operator import itemgetter

A, B, C, D, E, F = list(map(int,input().split()))
X = []
ans = 1000
for i in range(31):
    for j in range(31):
        for k in range(51):
            for l in range(51):
                if 100*A*i+100*B*j+C*k+D*l != 0:
                    if 100*A*i+100*B*j+C*k+D*l <= F and (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l) <= E/(100 + E):
                        ans =(E/(100 + E) - (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l))
                        X.append([ans , 100*A*i+100*B*j+C*k+D*l, C*k+D*l])
X = sorted(X,key=itemgetter(0),reverse = False) 

print(X[0][1],X[0][2])
### BUGGY CODE ###

import math

n = int(input())
aL = list(map(int, input().split(" ")))
q = int(input())
bcL = [list(map(int, input().split(" "))) for _ in range(q)]

sums = [0 for i in range(10**5 + 1)]

for a in aL:
    sums[a] += 1

for b, c in bcL:
    sums[c] += sums[b]
    sums[b] = 0
    _sum = 0
    for i, s in enumerate(sums):
        _sum += i * s
    print(_sum)

### FIXED CODE ###

import math

n = int(input())
aL = list(map(int, input().split(" ")))
q = int(input())
bcL = [list(map(int, input().split(" "))) for _ in range(q)]

sums = [0 for i in range(10**5 + 1)]

for a in aL:
    sums[a] += 1

_sum = 0
for i, a in enumerate(sums):
    _sum += i * a

for b, c in bcL:
    _sum += (c - b) * sums[b]

    sums[c] += sums[b]
    sums[b] = 0
    print(_sum)
### BUGGY CODE ###

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

h = []
for i in range(n):
    h.append(int(input()))
hc = [0]*n
st,ed = 0,10**9+1
while st<ed-1:
    mid = (st+ed)//2
    #print(mid)
    tmp = 0
    for i in range(n):
        hc[i]=h[i]-mid*b
    for i in range(n):
        tmp+=(hc[i]//(a-b))+(hc[i]%(a-b)>0)
    if tmp<=mid:
        ed = mid
    else:
        st = mid
print(ed) 


### FIXED CODE ###

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

h = []
for i in range(n):
    h.append(int(input()))
st,ed = 0,10**9+1
while st<ed-1:
    mid = (st+ed)//2
    #print(mid)
    tmp = 0
    for i in range(n):
        x = h[i]-mid*b
        if x>0:
            tmp+=(x//(a-b))+(x%(a-b)>0)
    if tmp<=mid:
        ed = mid
    else:
        st = mid
print(ed)
### BUGGY CODE ###

# coding: utf-8
num = int(input())
lines = list(int(i) for i in input().split())
lines.sort(reverse=True)
counter = 0

for i in range(num):
  for j in range(i+1, num):
    for k in range(j+1, num):
      if lines[i] < lines[j] + lines[k]:
        counter += 1
print(counter)


### FIXED CODE ###

import bisect
n = int(input())
lines = list(int(i) for i in input().split())
lines.sort()
counter = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
    
print(counter)
### BUGGY CODE ###


def isDead(pos):
    nPos = pos
    for magic in td:
        if S[nPos] == magic[0]:
            if magic[1] == 'L':
                nPos -= 1
            else:
                nPos += 1
                pass
            pass

        if (nPos < 0) or (nPos > N-1):
            return True
            pass
        pass # end for
    return False

N, Q = map(int, input().split())
S = input()
td = [input().split() for _ in range(Q)]


left = 0
right = N-1
while(left <= N-1):
    if(isDead(left) == False):
        break
    left += 1
    pass

while(right >= left):
    if(isDead(right) == False):
        break
    right -= 1
    pass
#left   #左側から死んだ数
#N-1 - right  #右側から死んだ数

alive = right - left + 1

print(alive)


### FIXED CODE ###

# ある位置のゴーレムが
# 左端にたどりつくか、右端にたどりつくか、生きているか、を
# 判別する関数
# 戻り値 -1:左端、0:生存、1:右端
def isDead(pos):
    nPos = pos
    if (nPos < 0):
        return -1
    elif (nPos > N-1):
        return 1

    for magic in td:        
        if S[nPos] == magic[0]:
            if magic[1] == 'L':
                nPos -= 1
            else:
                nPos += 1

        if (nPos < 0):
            return -1
        elif (nPos > N-1):
            return 1

        pass # end for
    return 0

N, Q = map(int, input().split())
S = input()
td = [input().split() for _ in range(Q)]

# 二分法で左側の解を求める
lAns = -1
if isDead(0) > -1:
    # 解なし
    lAns = -1
    pass
else:
    tmpMin = -1
    tmpMax = N
    tmp = N // 2
    while( (tmpMax - tmpMin) > 1):
        tmp = (tmpMin + tmpMax) // 2
        if(isDead(tmp) == -1):
            tmpMin = tmp
        else:
            tmpMax = tmp
        pass

    lAns = tmpMin
    # 左側死んだ数 = lAns + 1



# 二分法で右側の解を求める
rAns = N-1
if isDead(N-1) < 1:
    # 解なし
    rAns = N-1
    pass
else:
    tmpMin = -1
    tmpMax = N
    tmp = N // 2
    while( (tmpMax - tmpMin) > 1):
        tmp = (tmpMin + tmpMax) // 2
        if(isDead(tmp) == 1):
            tmpMax = tmp
        else:
            tmpMin = tmp
        pass

    rAns = tmpMin
    # 右側死んだ数 = N - (rAns+1)


alive = rAns - lAns

print(alive)
### BUGGY CODE ###

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

A_sort=sorted(A)
ANSMIN=0
ANSMAX=N-1
cums=[None]*(N+1)

def midup(x):
    cums[0]=0
    for i in range(N):
        if A[i]>=x:
            cums[i+1]=cums[i]+1
        else:
            cums[i+1]=cums[i]-1

    MINS=min(cums)
    MAXS=max(cums)

    #print(MINS,MAXS,cums)

    bitlist=[0 for i in range(MAXS-MINS+2)]#出現個数をbit indexed treeの形でもっておく.

    NUM=0#iまでで,s_k<=s_iとなるものの個数

    for i in range(N+1):
        bitobje=cums[i]-MINS+1
        #print(i,bitobje)

        x=bitobje
        while x!=0:
            NUM+=bitlist[x]
            x-=(x&(-x))

        while bitobje<=MAXS-MINS+1:
            bitlist[bitobje]+=1

            #print(i,bitobje,bitlist)
            
            bitobje+=(bitobje &(-bitobje))

        #print(i,bitlist,NUM)

            

    #print(NUM,cums,bitlist)

    if NUM>=(N+1)*N//2/2:
        return 1
    else:
        return 0





while True:
    candi=A_sort[(ANSMIN+ANSMAX)//2]

    if midup(candi)==1:#中央値がx以上なら1を返す！
        ANSMIN=(ANSMIN+ANSMAX)//2
    else:
        ANSMAX=(ANSMIN+ANSMAX)//2

    if A_sort[ANSMIN]==A_sort[ANSMAX]:
        print(A_sort[ANSMIN])
        break
    if ANSMIN+1==ANSMAX:
        if midup(A_sort[ANSMAX])==1:
            print(A_sort[ANSMAX])
            break
        else:
            print(A_sort[ANSMIN])
            break



    
    


### FIXED CODE ###

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

A_sort=sorted(A)
ANSMIN=0
ANSMAX=N-1
cums=[None]*(N+1)

def midup(x):
    cums[0]=0
    for i in range(N):
        if A[i]>=x:
            cums[i+1]=cums[i]+1
        else:
            cums[i+1]=cums[i]-1

    MINS=min(cums)
    MAXS=max(cums)

    #print(MINS,MAXS,cums)

    bitlist=[0 for i in range(MAXS-MINS+2)]#出現個数をbit indexed treeの形でもっておく.

    NUM=0#iまでで,s_k<=s_iとなるものの個数

    for i in range(N+1):
        bitobje=cums[i]-MINS+1
        #print(i,bitobje)

        x=bitobje
        while x!=0:
            NUM+=bitlist[x]
            x-=(x&(-x))

        while bitobje<=MAXS-MINS+1:
            bitlist[bitobje]+=1
          
            bitobje+=(bitobje &(-bitobje))

    if NUM>=(N+1)*N//2/2:
        return 1
    else:
        return 0


while True:
    candi=A_sort[(ANSMIN+ANSMAX)//2]

    if midup(candi)==1:#中央値がx以上なら1を返す！
        ANSMIN=(ANSMIN+ANSMAX)//2
    else:
        ANSMAX=(ANSMIN+ANSMAX)//2

    if A_sort[ANSMIN]==A_sort[ANSMAX]:
        print(A_sort[ANSMIN])
        break
    if ANSMIN+1==ANSMAX:
        if midup(A_sort[ANSMAX])==1:
            print(A_sort[ANSMAX])
            break
        else:
            print(A_sort[ANSMIN])
            break
### BUGGY CODE ###

# coding: utf-8
from sys import setrecursionlimit


def dfs(node: int):
    if checked[node]:
        return

    checked[node] = True
    chain.add(node)
    for n in friends[node]:
        dfs(n)


def solve(*args: str) -> str:
    setrecursionlimit(2 * 10 ** 9)
    n, m, k = map(int, args[0].split())

    global friends
    friends = {i: set() for i in range(n+1)}
    blocked = {i: set() for i in range(n+1)}

    for a, b in map(str.split, args[1:1+m]):
        friends[int(a)].add(int(b))
        friends[int(b)].add(int(a))

    for c, d in map(str.split, args[1+m:1+m+k]):
        blocked[int(c)].add(int(d))
        blocked[int(d)].add(int(c))

    global checked
    checked = [False]*(n+1)

    ret = [0]*(n+1)
    for a in range(1, n+1):
        if checked[a]:
            continue

        global chain
        chain = set()
        dfs(a)
        for i in chain:
            ret[i] += len(chain-friends[i]-blocked[i]) - 1

    return ' '.join(map(str, ret[1:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


### FIXED CODE ###

# coding: utf-8
from sys import setrecursionlimit


def dfs(node: int):
    if checked[node]:
        return

    checked[node] = True
    chain.add(node)
    for n in friends[node]:
        dfs(n)


def solve(*args: str) -> str:
    setrecursionlimit(2 * 10 ** 9)
    n, m, k = map(int, args[0].split())

    global friends
    friends = {i: set() for i in range(n+1)}
    blocked = {i: set() for i in range(n+1)}

    for a, b in map(str.split, args[1:1+m]):
        friends[int(a)].add(int(b))
        friends[int(b)].add(int(a))

    for c, d in map(str.split, args[1+m:1+m+k]):
        blocked[int(c)].add(int(d))
        blocked[int(d)].add(int(c))

    global checked
    checked = [False]*(n+1)

    ret = [0]*(n+1)
    for a in range(1, n+1):
        if checked[a]:
            continue

        global chain
        chain = set()
        dfs(a)
        count = len(chain) - 1
        for i in chain:
            ret[i] += count - len(chain & (friends[i] | blocked[i]))

    return ' '.join(map(str, ret[1:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
### BUGGY CODE ###

from collections import deque
S = list(input())
Q = int(input())

d = deque()
d.extend(S)
for i in range(1, Q+1):
    query = input()
    if len(query) == 1:
        d.reverse()
    else:
        n, F, C = query.split()
        if F == '1':
            d.appendleft(C)
        else:
            d.append(C)

l = list(d)
S = ''.join(l)
print(S)


### FIXED CODE ###

from collections import deque
S = list(input())
Q = int(input())

d = deque()
d.extend(S)
cnt = 0
for i in range(1, Q+1):
    query = input()
    if len(query) == 1:
        cnt += 1
    else:
        n, F, C = query.split()
        if cnt % 2 == 0:  # 反転cntが偶数,F=1で末尾
            if F == '1':
                d.appendleft(C)
            else:
                d.append(C)
        else:  # 反転cntが偶数,F=1で先頭
            if F == '1':
                d.append(C)
            else:
                d.appendleft(C)

if cnt % 2 == 1:  # cnt奇数の場合、反転
    d.reverse()
else:
    pass

l = list(d)
S = ''.join(l)
print(S)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
 
N,M = list(map(int,input().split()))
A = [int(input()) for _ in range(M)]
 
a2 = 1
a1 = 0 if 1 in A else 1 
for i in range(2,N+1):
    a = 0 if i in A else a2+a1
    a2 = a1
    a1 = a
    if a1 == 0 and a2 == 0:
        break
print(1 if N == 1 else a%1000000007)


### FIXED CODE ###

n,m = map(int,input().split())
a = [ int(input()) for _ in range(m)]
M=10**9+7
lis = [1] + [0]*n

for i in a:
  lis[i]=-1
lis[1] += 1
for i in range(n-1):
  if lis[i+2]<0:
    lis[i+2]= 0
  else:
    lis[i+2] = (lis[i+1] + lis[i])%M
print(lis[n])