#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long s, b;
  cin >> s >> b;
  vector<long long> a(s);
  for (long long i = 0; i < s; i++) cin >> a[i];
  vector<pair<long long, long long>> g(b);
  for (long long i = 0; i < b; i++) cin >> g[i].first >> g[i].second;
  sort(g.begin(), g.end());
  for (long long i = 1; i < b; i++) {
    g[i].second += g[i - 1].second;
  }
  for (long long i = 0; i < s; i++) {
    auto f =
        lower_bound(g.begin(), g.end(), make_pair(a[i] + 1, 0ll)) - g.begin();
    if (f != 0)
      cout << g[f - 1].second << " ";
    else
      cout << "0 ";
  }
  cout << "\n";
  return 0;
}
