#include <bits/stdc++.h>
using namespace std;
struct node {
  long long b;
  long long c;
  bool operator<(node x) const { return b < x.b; }
};
signed main() {
  long long n, m;
  cin >> n >> m;
  long long a[n + 1];
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  node b[m + 2];
  for (long long i = 1; i <= m; ++i) cin >> b[i].b >> b[i].c;
  b[0].c = 0;
  b[0].b = 0;
  b[m + 1].b = 10000000000000;
  sort(b, b + m + 2);
  for (long long i = 1; i <= m; ++i) b[i].c += b[i - 1].c;
  for (long long i = 1; i <= n; ++i) {
    long long l = 0;
    long long r = m + 1;
    while (l + 1 < r) {
      long long mid = (l + r) / 2;
      if (b[mid].b <= a[i])
        l = mid;
      else
        r = mid;
    }
    cout << b[l].c << ' ';
  }
  cout << endl;
}
