#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
struct node {
  int d, g, sum;
  node(int d1 = 0, int g1 = 0, int s1 = 0) : d(d1), g(g1), sum(s1) {}
  bool operator<(const node &n1) const { return d < n1.d; }
} x[100003];
int n, a[100003];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int i, j, t, s, b;
  cin >> s >> b;
  for (i = 0; i < s; i++) cin >> a[i];
  for (i = 1; i <= b; i++) cin >> x[i].d >> x[i].g;
  sort(x + 1, x + b + 1);
  for (i = 1; i <= b; i++) {
    x[i].sum = x[i - 1].sum + x[i].g;
  }
  for (i = 0; i < s; i++) {
    node tmp = node(a[i], 0, 0);
    int k = upper_bound(x + 1, x + b + 1, tmp) - x;
    if (k == 1)
      cout << 0 << ' ';
    else {
      cout << x[k - 1].sum << ' ';
    }
  }
  cout << endl;
  return 0;
}
