#include <bits/stdc++.h>
using namespace std;
int m, n, c, d, j, k, l, r, x = 1e5, t, y, u, z, i, e, f, g, h, s, b;
int main() {
  int a[x];
  cin >> s >> b;
  pair<int, int> p[b];
  for (i = 0; i < s; i++) {
    cin >> a[i];
  }
  for (i = 0; i < b; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p + b);
  for (i = 0; i < s; i++) {
    int f = lower_bound(p, p + b, make_pair(a[i], 10000000)) - p;
    c = 0;
    for (j = 0; j < f; j++) {
      c += p[j].second;
    }
    cout << c << " ";
  }
  return 0;
}
