#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long s, b;
  cin >> s >> b;
  long long a[s];
  for (long long i = 0; i < s; i++) cin >> a[i];
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < b; i++) {
    long long x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end());
  long long dp[b];
  vector<long long> v1(b);
  dp[0] = v[0].second;
  v1[0] = v[0].first;
  vector<long long>::iterator it;
  for (long long i = 1; i < b; i++) {
    dp[i] = dp[i - 1] + v[i].second;
    v1[i] = v[i].first;
  }
  for (long long i = 0; i < s; i++) {
    it = upper_bound(v1.begin(), v1.end(), a[i]);
    if (it == v1.begin()) {
      cout << 0 << " ";
      continue;
    }
    it--;
    cout << dp[it - v1.begin()] << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
