#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 20;
int n, m, now = 1;
struct def {
  long long val, gold;
} d[maxn];
bool cmp_def_val(def x, def y) { return x.val < y.val; }
struct atk {
  long long val, num, res;
} a[maxn];
bool cmp_atk_val(atk x, atk y) { return x.val < y.val; }
bool cmp_atk_num(atk x, atk y) { return x.num < y.num; }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i].val, a[i].num = i;
  for (int i = 1; i <= m; i++) cin >> d[i].val >> d[i].gold;
  sort(a + 1, a + 1 + n, cmp_atk_val);
  sort(d + 1, d + 1 + m, cmp_def_val);
  for (int i = 1; i <= n; i++) {
    a[i].res = a[i - 1].res;
    while (now <= m && a[i].val >= d[now].val) a[i].res += d[now++].gold;
  }
  sort(a + 1, a + 1 + n, cmp_atk_num);
  for (int i = 1; i <= n; i++) cout << a[i].res << " ";
  return 0;
}
