#include <bits/stdc++.h>
using namespace std;
int main() {
  int s, b;
  cin >> s >> b;
  int attack[s];
  for (int i = 0; i < s; i++) {
    cin >> attack[i];
  }
  long long int d, g;
  vector<pair<long long int, long long int>> defence;
  for (int i = 0; i < b; i++) {
    cin >> d >> g;
    defence.push_back(make_pair(d, g));
  }
  sort((defence).begin(), (defence).end());
  long long int temp = 0;
  for (auto it = defence.begin(); it != defence.end(); it++) {
    it->second += temp;
    temp = it->second;
  }
  vector<int> def(b);
  vector<long long int> ans(b);
  for (auto it = defence.begin(); it != defence.end(); it++) {
    def.push_back(it->first);
    ans.push_back(it->second);
  }
  for (int i = 0; i < s; i++) {
    auto it = lower_bound((def).begin(), (def).end(), attack[i]);
    if (*it != attack[i]) it = it - 1;
    int id = it - def.begin();
    cout << ans[id] << " ";
  }
}
