#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long s, b, a[100005], d[100005][4], i;
  long long ans[100005];
  cin >> s >> b;
  for (i = 1; i <= s; i++) {
    cin >> a[i];
    ans[i] = 0;
  }
  map<long long, long long> fr;
  map<long long, long long>::iterator itr;
  long long mex = 0;
  for (i = 1; i <= b; i++) {
    cin >> d[i][1] >> d[i][2];
    fr[d[i][1]] += d[i][2];
  }
  long long q2 = 0;
  for (i = 1; i <= b; i++) {
    if (mex < d[i][1]) mex = d[i][1];
    q2 += d[i][2];
  }
  auto itrr = fr.end();
  itrr--;
  long long q1 = (*itrr).first;
  cerr << endl << q1 << " " << q2 << endl;
  for (itr = fr.begin(); itr != itrr; ++itr) {
    map<long long, long long>::iterator it = ++itr;
    --itr;
    it->second += itr->second;
  }
  for (itr = fr.begin(); itr != fr.end(); ++itr) {
    cerr << '\t' << itr->first << '\t' << itr->second << '\n';
  }
  for (i = 1; i <= s; i++) {
    if (a[i] >= mex) {
      cout << q2 << " ";
    } else {
      itrr = fr.upper_bound(a[i]);
      if (itrr == fr.begin()) {
        cout << 0 << " ";
      } else {
        itrr--;
        cout << (*itrr).second << " ";
      }
    }
  }
  return 0;
}
