#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s, b;
  cin >> s >> b;
  vector<long long> ship;
  for (long long i = 0; i < s; i++) {
    long long x;
    cin >> x;
    ship.push_back(x);
  }
  vector<pair<long long, long long>> base;
  for (long long i = 0; i < b; i++) {
    long long x, y;
    cin >> x >> y;
    base.push_back({x, y});
  }
  sort((base).begin(), (base).end());
  for (long long i = 1; i < b; i++) base[i].second += base[i - 1].second;
  for (auto x : ship) {
    auto y =
        lower_bound((base).begin(), (base).end(), make_pair(x, (long long)0)) -
        base.begin();
    if (y >= b or base[y].first > x) y--;
    if (y >= 0)
      cout << base[y].second << " ";
    else
      cout << 0 << " ";
  }
  return 0;
}
