#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int nax = 1e5 + 10;
vector<int> tree(4 * nax);
long long i, j, x, y;
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, cnt = 0;
  cin >> n >> m;
  vector<long long> b, ans;
  for (int i = 0; i < n; i++) {
    cin >> x;
    b.push_back(x);
  }
  vector<pair<long long, long long>> a, c;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    a.push_back(make_pair(x, y));
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < m; i++) {
    cnt += a[i].second;
    c.push_back(make_pair(a[i].first, cnt));
  }
  for (int i = 0; i < n; i++) {
    long long l = 0, r = a.size(), d = 0;
    while (l < r) {
      long long mp = (l + r) / 2;
      if (b[i] < c[mp].first) {
        r = mp;
      } else {
        l = mp + 1;
        d = mp;
      }
    }
    if (c[d].first <= b[i])
      cout << c[d].second << " ";
    else
      cout << 0 << " ";
  }
}
