#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long s, b;
  cin >> s >> b;
  vector<long long> a(s);
  unordered_map<long long, long long> k;
  set<long long> c;
  vector<pair<long long, long long> > d(b, make_pair(0, 0));
  for (long long i = 0; i < s; i++) {
    cin >> a[i];
    c.insert(a[i]);
  }
  for (long long i = 0; i < b; i++) cin >> d[i].first >> d[i].second;
  sort(begin(d), end(d));
  long long cur = 0, j = 0;
  for (long long i : c) {
    while (j < b && i >= d[j].first) cur += d[j].second, j++;
    k[i] = cur;
  }
  for (long long i = 0; i < s; i++) cout << k[a[i]] << ' ';
}
