#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, b;
  cin >> n >> b;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];
  vector<pair<int, long long> > base(b);
  for (int i = 0; i < b; ++i) cin >> base[i].first >> base[i].second;
  sort(base.begin(), base.end());
  for (int i = 1; i < b; ++i) base[i].second += base[i - 1].second;
  for (int i = 0; i < n; ++i) {
    int lo = 0, hi = b - 1, mid;
    while (lo <= hi) {
      mid = (lo + hi) / 2;
      if (base[mid].first <= arr[i]) {
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
    if (arr[i] < base[0].first)
      cout << 0 << " ";
    else
      cout << base[lo - 1].second << " ";
  }
  cout << endl;
  return 0;
}
