#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e15;
const long long md = (long long)1e9 + 7;
const long long MAXN = (long long)1e4 + 10;
const long long N = 300000;
long long bpow(long long a, long long b) {
  if (b == 0) return 1ll;
  if (b % 2 == 0) {
    long long t = bpow(a, b / 2);
    return t * t;
  }
  return a * bpow(a, b - 1);
}
void init() { return; }
void solve_case() {
  long long n, k;
  cin >> n >> k;
  multiset<long long> st;
  long long ans[n + 1];
  vector<pair<long long, long long> > v;
  long long power[n + 1];
  long long money[n + 1];
  for (long long i = 0; i < n; i++) {
    cin >> power[i];
    v.push_back(make_pair(power[i], i));
  }
  for (long long i = 0; i < n; i++) {
    cin >> money[i];
    st.insert(-money[i]);
  }
  sort(v.rbegin(), v.rend());
  for (long long i = 0; i < n; i++) {
    long long id = v[i].second;
    long long cur = money[id];
    st.erase(st.find(-money[id]));
    long long c = 0;
    for (auto x : st) {
      if (c == k) break;
      cur -= x;
      c++;
    }
    ans[id] = cur;
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  init();
  long long t = 1;
  for (long long _ = 1; _ <= t; _++) {
    solve_case();
  }
  return 0;
}
