#include <bits/stdc++.h>
using namespace std;
long long inf = 1e16;
long long mod = 1e9 + 9;
char en = '\n';
long long abs1(long long x) {
  if (x < 0) return -x;
  return x;
}
long long power(long long x, long long n, long long mod) {
  long long res = 1;
  x %= mod;
  while (n) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
long long MAXDIST = 1e16;
struct edge {
  long long to, flow, cap;
  long long cost;
  long long rev;
};
struct MinCostMaxFlow {
  long long nodes;
  vector<long long> curflow, prevedge, prevnode, q;
  vector<long long> pot, prio;
  vector<bool> inqueue;
  vector<vector<edge>> graph;
  MinCostMaxFlow() {}
  MinCostMaxFlow(long long n)
      : nodes(n),
        prio(n, 0),
        curflow(n, 0),
        prevedge(n, 0),
        prevnode(n, 0),
        q(n, 0),
        pot(n, 0),
        inqueue(n, 0),
        graph(n) {}
  void addEdge(long long source, long long to, long long capacity,
               long long cost) {
    edge a = {to, 0, capacity, cost, (long long)graph[to].size()};
    edge b = {source, 0, 0, -cost, (long long)graph[source].size()};
    graph[source].push_back(a);
    graph[to].push_back(b);
  }
  void bellman_ford(long long source, vector<long long> &dist) {
    fill(dist.begin(), dist.end(), MAXDIST);
    dist[source] = 0;
    long long qt = 0;
    q[qt++] = source;
    for (long long qh = 0; (qh - qt) % nodes != 0; qh++) {
      long long u = q[qh % nodes];
      inqueue[u] = false;
      for (auto &e : graph[u]) {
        if (e.flow >= e.cap) continue;
        long long v = e.to;
        long long newDist = dist[u] + e.cost;
        if (dist[v] > newDist) {
          dist[v] = newDist;
          if (!inqueue[v]) {
            inqueue[v] = true;
            q[qt++ % nodes] = v;
          }
        }
      }
    }
  }
  pair<long long, long long> minCostFlow(long long source, long long dest,
                                         long long maxflow) {
    bellman_ford(source, pot);
    long long flow = 0;
    long long flow_cost = 0;
    while (flow < maxflow) {
      priority_queue<pair<long long, long long>,
                     vector<pair<long long, long long>>,
                     greater<pair<long long, long long>>>
          q;
      q.push({0, source});
      fill(prio.begin(), prio.end(), MAXDIST);
      prio[source] = 0;
      curflow[source] = INT_MAX;
      while (!q.empty()) {
        long long d = q.top().first;
        long long u = q.top().second;
        q.pop();
        if (d != prio[u]) continue;
        for (long long i = 0; i < graph[u].size(); i++) {
          edge &e = graph[u][i];
          long long v = e.to;
          if (e.flow >= e.cap) continue;
          long long newPrio = prio[u] + e.cost + pot[u] - pot[v];
          if (prio[v] > newPrio) {
            prio[v] = newPrio;
            q.push({newPrio, v});
            prevnode[v] = u;
            prevedge[v] = i;
            curflow[v] = min(curflow[u], e.cap - e.flow);
          }
        }
      }
      if (prio[dest] == MAXDIST) break;
      for (long long i = 0; i < nodes; i++) pot[i] += prio[i];
      long long df = min(curflow[dest], maxflow - flow);
      flow += df;
      for (long long v = dest; v != source; v = prevnode[v]) {
        edge &e = graph[prevnode[v]][prevedge[v]];
        e.flow += df;
        graph[v][e.rev].flow -= df;
        flow_cost += df * e.cost;
      }
    }
    return {flow, flow_cost};
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long arr[n + 5], arr2[n + 5];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  for (long long i = 0; i < n; i++) cin >> arr2[i];
  MinCostMaxFlow obj(n + 3);
  long long dest = n + 2;
  for (long long i = 0; i < n; i++) {
    obj.addEdge(0, i + 1, 1, arr[i]);
    obj.addEdge(i + 1, dest, 1, arr2[i]);
    if (i != n - 1) obj.addEdge(i + 1, i + 2, n + 5, 0);
  }
  long long src = n + 1;
  obj.addEdge(src, 0, k, 0);
  pair<long long, long long> res = obj.minCostFlow(src, dest, inf);
  if (res.first != k) {
    cout << -1 << en;
  } else
    cout << res.second << en;
  return 0;
}
