#include <bits/stdc++.h>
using namespace std;
int N, Q;
int V[100004];
struct elem {
  int d, g;
} x[100004];
long long ans[100004];
bool cmp(elem a, elem b) { return a.d < b.d; }
int bin_search(int xf) {
  int pw = 1;
  while (pw <= Q) {
    pw <<= 1;
  }
  pw >>= 1;
  int pos = 0;
  while (pw) {
    if (pos + pw <= Q) {
      if (x[pos + pw].d <= xf) {
        pos += pw;
      }
    }
    pw >>= 1;
  }
  return pos;
}
int main() {
  cin >> N >> Q;
  for (int i = 1; i <= N; ++i) {
    cin >> V[i];
  }
  for (int i = 1; i <= Q; ++i) {
    cin >> x[i].d >> x[i].g;
  }
  sort(x + 1, x + 1 + Q, cmp);
  for (int i = 1; i <= Q; ++i) {
    ans[i] = ans[i - 1] + x[i].g * 1LL;
  }
  for (int i = 1; i <= N; ++i) {
    int pos = bin_search(V[i]);
    cout << ans[pos] << ' ';
  }
  return 0;
}
