#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s, b, ans = 0;
  cin >> s >> b;
  long long a[s];
  for (long long i = 0; i < s; i++) {
    cin >> a[i];
  }
  vector<pair<long long, long long> > vp(b);
  for (long long i = 0; i < b; i++) {
    cin >> vp[i].first >> vp[i].second;
  }
  sort(vp.begin(), vp.end());
  long long pref[b];
  pref[0] = vp[0].second;
  for (long long i = 1; i < b; i++) {
    pref[i] = pref[i - 1] + vp[i].second;
  }
  for (long long i = 0; i < s; i++) {
    ans = 0;
    if (a[i] < vp[0].first) {
      cout << "0"
           << " ";
      continue;
    }
    long long left =
        lower_bound(vp.begin(), vp.end(), make_pair(a[i], -1LL)) - vp.begin();
    if (left == b) {
      cout << pref[b - 1] << " ";
      continue;
    }
    if (vp[left].first == a[i])
      while (left < b && vp[left].first == a[i]) {
        left++;
      }
    else {
      left--;
      cout << pref[left] << " ";
      continue;
    }
    cout << pref[left - 1] << " ";
  }
}
