#include <bits/stdc++.h>
using namespace std;
priority_queue<long long, vector<long long>, greater<long long>> pq1, pq2;
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    res *= a;
    b--;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, l, h, mi, x, y, sum = 0, pre[200005], q[200005];
  vector<pair<long long, long long>> v;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> q[i];
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    v.push_back({x, y});
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    long long st = v[i].second;
    sum += st;
    pre[i] = sum;
  }
  for (int i = 0; i < n; ++i) {
    long long st = q[i];
    l = 0;
    h = m - 1;
    long long ans = -1;
    while (l <= h) {
      mi = (l + h) / 2;
      if (v[mi].first > st) {
        h = mi - 1;
      } else {
        l = mi + 1;
        ans = mi;
      }
    }
    if (ans == -1)
      cout << "0"
           << " ";
    else
      cout << pre[ans] << " ";
  }
  cout << endl;
  return 0;
}
