#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s, b;
  cin >> s >> b;
  vector<long long> a(s), cum_sum(b);
  for (int i = 0; i < s; i++) {
    cin >> a[i];
  }
  vector<pair<long long, long long> > vpr(b);
  vector<long long> res(b);
  long long d, g;
  for (int i = 0; i < b; i++) {
    cin >> d >> g;
    vpr[i].first = d;
    vpr[i].second = g;
    res[i] = d;
  }
  sort(vpr.begin(), vpr.end());
  for (int i = 0; i < b; i++) {
    if (i) {
      cum_sum[i] = cum_sum[i - 1] + vpr[i].second;
    } else {
      cum_sum[i] = vpr[i].second;
    }
  }
  sort(res.begin(), res.end());
  for (int i = 0; i < s; i++) {
    int pos = lower_bound(res.begin(), res.end(), a[i]) - res.begin();
    if (pos == res.size()) {
      cout << cum_sum[pos - 1] << " ";
      continue;
    }
    if (res[pos] == a[i]) {
      cout << cum_sum[pos] << " ";
    } else {
      if (pos)
        cout << cum_sum[pos - 1] << " ";
      else
        cout << 0 << endl;
    }
  }
  return 0;
}
