#include <bits/stdc++.h>
using namespace std;
struct space {
  int first;
  int second;
  int third;
};
bool compare(struct space a, struct space b) {
  if (a.first < b.first) return true;
  return false;
}
bool compare2(struct space a, struct space b) {
  if (a.second < b.second) return true;
  return false;
}
int main() {
  int s, b;
  cin >> s >> b;
  vector<space> a(s);
  for (int i = 0; i < s; i++) {
    cin >> a[i].first;
    a[i].second = i;
    a[i].third = 0;
  }
  vector<pair<int, int>> dog(b);
  for (int i = 0; i < b; i++) {
    cin >> dog[i].first >> dog[i].second;
  }
  sort(dog.begin(), dog.end());
  sort(a.begin(), a.end(), compare);
  int i = 0;
  int j = 0;
  int count = 0;
  while (i < s && j < b) {
    if (a[i].first >= dog[j].first) {
      count += dog[j].second;
      j++;
    } else {
      a[i].third = count;
      i++;
    }
  }
  while (i < s) {
    a[i].third = count;
    i++;
  }
  sort(a.begin(), a.end(), compare2);
  for (int i = 0; i < a.size(); i++) cout << a[i].third << " ";
  return 0;
}
