#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long int mod = 1e9 + 7;
const long long int MAX = LLONG_MAX;
const long long int MIN = LLONG_MIN;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int s, b;
  cin >> s >> b;
  long long int c = b;
  long long int a[s];
  for (long long int i = 0; i < s; i++) cin >> a[i];
  vector<long long int> v;
  vector<pair<long long int, long long int>> vv;
  while (c--) {
    long long int p, g;
    cin >> p >> g;
    v.push_back(p);
    vv.push_back(make_pair(p, g));
  }
  sort(v.begin(), v.end());
  sort(vv.begin(), vv.end());
  long long int gold[b];
  for (long long int i = 0; i != vv.size(); i++) {
    if (i == 0) {
      gold[i] = vv[i].second;
    } else {
      gold[i] = gold[i - 1] + vv[i].second;
    }
  }
  for (long long int i = 0; i < s; i++) {
    auto itr = upper_bound(v.begin(), v.end(), a[i]) - v.begin();
    if (itr == b) itr--;
    if (v[itr] > a[i]) {
      itr--;
    }
    if (itr < 0)
      cout << 0 << " ";
    else
      cout << gold[itr] << " ";
  }
  return 0;
}
