802_N. April Fools' Problem (medium)
The marmots need to prepare k problems for HC2 over n days. Each problem, once prepared, also has to be printed.

The preparation of a problem on day i (at most one per day) costs ai CHF, and the printing of a problem on day i (also at most one per day) costs bi CHF. Of course, a problem cannot be printed before it has been prepared (but doing both on the same day is fine).

What is the minimum cost of preparation and printing?

Input

The first line of input contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 2200). The second line contains n space-separated integers a1, ..., an (<image>) — the preparation costs. The third line contains n space-separated integers b1, ..., bn (<image>) — the printing costs.

Output

Output the minimum cost of preparation and printing k problems — that is, the minimum possible sum ai1 + ai2 + ... + aik + bj1 + bj2 + ... + bjk, where 1 ≤ i1 < i2 < ... < ik ≤ n, 1 ≤ j1 < j2 < ... < jk ≤ n and i1 ≤ j1, i2 ≤ j2, ..., ik ≤ jk.

Example

Input

8 4
3 8 7 9 9 4 6 8
2 5 9 4 3 8 9 1


Output

32

Note

In the sample testcase, one optimum solution is to prepare the first problem on day 1 and print it on day 1, prepare the second problem on day 2 and print it on day 4, prepare the third problem on day 3 and print it on day 5, and prepare the fourth problem on day 6 and print it on day 8.
```python
from collections import deque
from heapq import heappop, heappush
 
class Edge(object):
    __slots__ = ('x', 'y', 'cap', 'cost', 'inv')
    def __repr__(self):
        return '{e.x}-->{e.y} ({e.cap} , {e.cost})'.format(e=self)

class MCFP(list):
    def add(G, x, y, cap, cost):
        n = max(x, y) + 1
        while len(G)<n: G.append([])
        e = Edge() ; G[x].append(e)
        w = Edge() ; G[y].append(w)
        e.x=x ; e.y=y; e.cap=cap; e.cost=cost ; w.inv=e        
        w.x=y ; w.y=x; w.cap=0; w.cost=-cost ; e.inv=w
 
    def solve(G, src, tgt, flowStop=float('inf'), inf=float('inf')):
        flowVal = flowCost = 0
        n = len(G)
        G.inQ = [0]*n
        G.phi = h = [0]*n
        G.prev = p = [None]*n
        G.dist = d = [inf]*n
        G.SPFA(src)
        while p[tgt]!=None and flowVal<flowStop:
            b = [] ; x = tgt
            while x!=src: b.append(p[x]) ; x=p[x].x
            z = min(e.cap for e in b)
            for e in b: e.cap-=z ; e.inv.cap+=z
            flowVal += z
            flowCost += z * (d[tgt] - h[src] + h[tgt])
            for i in range(n):
                if p[i]!=None: h[i]+=d[i] ; d[i]=inf
            p[tgt] = None
            G.SPFA(src)
        return flowVal, flowCost

    def SPFA(G, src):
        inQ = G.inQ ; prev = G.prev
        d = G.dist ; h = G.phi
        d[src] = 0
        Q = deque([src])
        while Q:
            x = Q.popleft()
            inQ[x] = 0
            for e in G[x]:
                if e.cap <= 0: continue
                y = e.y ; dy = d[x] + h[x] + e.cost - h[y]
                if dy < d[y]:
                    d[y] = dy ; prev[y] = e
                    if inQ[y]==0:
                        inQ[y] = 1
                        if not Q or dy > d[Q[0]]: Q.append(y)
                        else: Q.appendleft(y)
        return

import sys, random
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)

def main():
    n, k = (next(ints) for i in range(2))
    a = [next(ints) for i in range(n)]
    b = [next(ints) for i in range(n)]
    G = MCFP()
    src, tgt = 2*n+1, 2*n+2
    for i in range(n):
        G.add(src, i, 1, 0)
        G.add(i, i+n, 1, a[i])
        G.add(i+n, tgt, 1, b[i])
        if i+1<n:
            G.add(i, i+1, n, 0)
            G.add(i+n, i+n+1, n, 0)
    flowVal, ans = G.solve(src, tgt, k)
    assert flowVal == k
    print(ans)
    #print(G)
    return

def test(n,k):
    R = random.Random(0)
    yield n ; yield k
    for i in range(n): yield R.randint(1, 10**9)
    for i in range(n): yield R.randint(1, 10**9)

#ints=test(1000, 800)

main()
```