Link to this code: https://cses.fi/paste/71a2857a38e37e31c5007b/
#include <bits/stdc++.h>
using namespace std;

#ifndef LOCAL
    #define dbg(...) (void(0))
    #define debug() if (0)
#endif

using i64 = int64_t;

// clang-format off
template<class T, class Cb> struct UpdateProxy {
    T &x;
    Cb cb;

    UpdateProxy(T &_x, Cb _cb) : x(_x), cb(_cb) {}

    operator T() const { return x; }
    auto &operator++() && { x++, cb(); return *this; }
    auto &operator--() && { x--, cb(); return *this; }
    auto &operator+=(const T &r) && { x += r, cb(); return *this; }
    auto &operator-=(const T &r) && { x -= r, cb(); return *this; }
    auto &operator*=(const T &r) && { x *= r, cb(); return *this; }
    auto &operator/=(const T &r) && { x /= r, cb(); return *this; }
    auto &operator%=(const T &r) && { x %= r, cb(); return *this; }
    auto &operator=(const T &r) && { x = r, cb(); return *this; }
    auto &operator<<=(const T &r) && { x <<= r, cb(); return *this; }
    auto &operator>>=(const T &r) && { x >>= r, cb(); return *this; }
    template<class F> auto &apply(F &&f) && { x = f(x), cb(); return *this; }
};
// clang-format on

template<class M> struct SegTree {
    using T = typename M::T;

    int n;
    vector<T> t;

    SegTree() {}
    SegTree(int _n) : n(_n), t(2 * n, M::id()) {}
    template<class V> SegTree(const V &v) : SegTree(int(v.size())) {
        copy_n(begin(v), n, begin(t) + n);
        for (int i = n; --i;) update(i);
    }

    auto operator[](int p) {
        UpdateProxy up{t[p + n], [this, p]() { update_from(p); }};
        return up;
    }
    template<class G> int max_right(int l, G &&g) {
        T sm = M::id();
        for (l += n; g(M::op(sm, t[l])) && l; l /= 2) {
            if (l & 1 && l > 1) sm = M::op(sm, t[l++]);
        }
        if (!l) return n;
        while (l < n) {
            if (g(M::op(sm, t[l <<= 1]))) sm = M::op(sm, t[l++]);
        }
        return l - n;
    }

    static int bit_ceil(int n) {
        int m = 1;
        while (m < n) m *= 2;
        return m;
    }
    void update(int p) { t[p] = M::op(t[p << 1], t[p << 1 | 1]); }
    void update_from(int p) {
        for (p += n; p >>= 1;) update(p);
    }
};

template<class _T> struct Max {
    using T = _T;
    static T id() { return numeric_limits<T>::min(); }
    static T op(T l, T r) { return max(l, r); }
};

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, q;
    cin >> n >> q;

    vector<int> a(n);
    for (int &i : a) cin >> i;

    SegTree<Max<int>> st(a);
    while (q--) {
        int r;
        cin >> r;
        int ans = st.max_right(0, [r](int mx) { return mx < r; });
        cout << (ans < n ? ans + 1 : 0) << " \n"[q == 0];
        if (ans < n) st[ans] -= r;
    }
}