#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, b, i, aa, bb, pt;
  cin >> n >> b;
  long long int a[n + 5], sm[b + 5];
  vector<pair<long long int, long long int> > v;
  vector<long long int> vv;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < b; i++) {
    cin >> aa >> bb;
    vv.push_back(aa);
    v.push_back({aa, bb});
  }
  sort(vv.begin(), vv.end());
  sort(v.begin(), v.end());
  sm[0] = v[0].second;
  for (i = 1; i < b; i++) {
    sm[i] = sm[i - 1] + v[i].second;
  }
  for (i = 0; i < n; i++) {
    pt = upper_bound(vv.begin(), vv.end(), a[i]) - vv.begin();
    if (pt == 0) {
      cout << 0 << " ";
      continue;
    }
    cout << sm[pt - 1] << " ";
  }
}
