#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int s, b;
  cin >> s >> b;
  vector<int> ships(s);
  for (int& a : ships) cin >> a;
  vector<pair<int, int>> bases(b);
  for (auto& e : bases) {
    cin >> e.first >> e.second;
  }
  sort(bases.begin(), bases.end());
  for (int i = 1; i < b; i++) {
    bases[i].second += bases[i - 1].second;
  }
  for (int a : ships) {
    int ans = 0;
    if (a >= bases[0].first) {
      auto it = lower_bound(bases.begin(), bases.end(), make_pair(a + 1, 0));
      ans = (it - 1)->second;
    }
    cout << ans << ' ';
  }
  cout << endl;
  return 0;
}
