#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct Q {
  int Def, Gold;
};
int n;
int m;
int cm[N];
int space[N];
map<int, int> compress;
vector<Q> queries;
int main() {
  scanf("%d%d", &n, &m);
  set<int> comp;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &space[i]);
    comp.insert(space[i]);
  }
  while (m--) {
    int D, G;
    scanf("%d%d", &D, &G);
    comp.insert(D);
    queries.push_back({D, G});
  }
  int data = 0;
  for (auto v : comp) {
    compress[v] = data;
    data++;
  }
  for (auto q : queries) {
    cm[compress[q.Def]] += q.Gold;
  }
  for (int i = 1; i <= 2e5; i++) {
    cm[i] += cm[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", cm[compress[space[i]]]);
  }
}
