#include <bits/stdc++.h>
using namespace std;

#define int long long
#define nn '\n'

const int N = 5e5 + 5;

int n, m;
int a[N], b[N];
int ps[N];
int mx[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;

    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= m; i++) cin >> b[i];

    sort(b + 1, b + m + 1);

    for(int i = 1; i <= m; i++){
        ps[i] = ps[i - 1] + b[i];
    }

    for(int i = 1; i <= m; i++){
        int need = b[i] - ps[i - 1];
        mx[i] = max(mx[i - 1], need);
    }

    for(int i = 1; i <= n; i++){
        int r = upper_bound(mx + 1, mx + m + 1, a[i]) - mx - 1;

        cout << a[i] + ps[r] << ' ';
    }

    return 0;
}