#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long second, b, l, r, mid, ans, i;
  cin >> second >> b;
  long long ar[second + 1];
  for (i = 1; i <= second; i++) cin >> ar[i];
  pair<long long, long long> dr[b + 1];
  for (i = 1; i <= b; i++) cin >> dr[i].first >> dr[i].second;
  sort(dr + 1, dr + b + 1);
  long long mx[b + 1], val;
  mx[1] = val = dr[1].second;
  for (i = 2; i <= b; i++) {
    mx[i] = dr[i].second + mx[i - 1];
  }
  for (i = 1; i <= second; i++) {
    l = 1;
    r = b;
    ans = -1;
    while (l <= r) {
      mid = l + (r - l) / 2;
      if (dr[mid].first <= ar[i]) {
        ans = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    if (ans == -1)
      cout << 0 << " ";
    else
      cout << mx[ans] << " ";
  }
  return 0;
}
