#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s, b;
  cin >> s >> b;
  vector<long long> a(s);
  vector<long long> d(b);
  map<long long, long long> m;
  map<long long, long long> ans;
  for (long long i = 0; i < s; i++) {
    cin >> a[i];
  }
  long long maxd = 0, mind = 1000000000;
  for (long long i = 0; i < b; i++) {
    long long x, y;
    cin >> x;
    cin >> y;
    if (x > maxd) maxd = x;
    if (x < mind) mind = x;
    m[x] += y;
    d[i] = x;
  }
  sort(d.begin(), d.end());
  long long sum = 0;
  for (auto it : m) {
    sum += it.second;
    ans[it.first] = sum;
  }
  for (long long i = 0; i < s; i++) {
    if (a[i] >= maxd) {
      cout << ans[maxd] << ' ';
      continue;
    }
    if (a[i] < mind) {
      cout << 0 << ' ';
      continue;
    }
    long long low = 0, high = b - 1;
    while (true) {
      long long mid = (low + high) / 2;
      if (a[i] == d[mid]) {
        cout << ans[d[mid]] << ' ';
        break;
      }
      if (low + 1 == high) {
        cout << ans[d[low]] << ' ';
        break;
      }
      if (a[i] < d[mid]) {
        high = mid;
      } else
        low = mid;
    }
  }
  return 0;
}
