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.
#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
struct MCMF {
  struct Edge {
    int u, v;
    int cap, cost;
    int prv;
    Edge(int u, int v, int cap, int cost, int prv)
        : u(u), v(v), cap(cap), cost(cost), prv(prv) {}
  };
  int src, snk;
  int par[(3000 + 99)];
  int flow;
  long long cost;
  int idxer;
  int last[(3000 + 99)];
  int n;
  vector<Edge> E;
  long long dist[(3000 + 99)];
  int state[(3000 + 99)];
  deque<int> Q;
  void init(int newN) {
    n = newN;
    memset(last, -1, sizeof last);
    E.clear();
    idxer = 0;
  }
  void add_edge(int u, int v, int cap, int cost) {
    Edge de = Edge(u, v, cap, cost, last[u]);
    Edge re = Edge(v, u, 0, -cost, last[v]);
    last[u] = idxer++;
    last[v] = idxer++;
    E.push_back(de);
    E.push_back(re);
  }
  bool SPFA(int st, int en) {
    static long long inf = 1e18 + 0.5;
    for (int i = 0; i < n; i++) dist[i] = inf, state[i] = 0;
    dist[st] = 0;
    state[st] = 1;
    Q.push_front(st);
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop_front();
      state[u] = 2;
      for (int i = last[u]; i != -1; i = E[i].prv) {
        Edge e = E[i];
        if (e.cap == 0) continue;
        int v = e.v;
        int cost = e.cost;
        long long nw = dist[u] + cost;
        if (dist[v] > nw) {
          dist[v] = nw;
          par[v] = i;
          if (state[v] == 0) Q.push_back(v);
          if (state[v] == 2) Q.push_front(v);
          state[v] = 1;
        }
      }
    }
    return dist[en] < inf;
  }
  void augment(int v, int minEdge = INT_MAX) {
    if (v == src) {
      cost = 0;
      flow = minEdge;
      return;
    }
    int idx = par[v];
    augment(E[idx].u, min(minEdge, E[idx].cap));
    E[idx].cap -= flow;
    E[idx ^ 1].cap += flow;
    cost += 1LL * flow * E[idx].cost;
  }
  pair<long long, long long> mcmf() {
    long long mf = 0, mc = 0;
    while (SPFA(src, snk)) {
      augment(snk);
      mf += flow;
      mc += cost;
    }
    return make_pair(mf, mc);
  }
};
int n, K;
const int MAXN = 2200 + 99;
int A[MAXN], B[MAXN];
MCMF graph;
int main() {
  read_file();
  while (scanf("%d%d", &n, &K) != -1) {
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    for (int i = 0; i < n; i++) scanf("%d", &B[i]);
    graph.init(n + 3);
    int src = n, snk = n + 1, srcc = n + 2;
    graph.add_edge(srcc, src, K, 0);
    graph.src = srcc, graph.snk = snk;
    for (int i = 0; i < n; i++) {
      graph.add_edge(src, i, 1, A[i]);
      graph.add_edge(i, snk, 1, B[i]);
      if (i != n - 1) graph.add_edge(i, i + 1, K, 0);
    }
    long long ans = graph.mcmf().second;
    printf("%lld\n", ans);
  }
}
