#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int s, b;
pair<long long, long long> a[MAXN];
pair<long long, long long> bases[MAXN];
long long ans[MAXN];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> s >> b;
  for (int i = 0; i < s; i++) cin >> a[i].first, a[i].second = i;
  for (int i = 0; i < b; i++) cin >> bases[i].first >> bases[i].second;
  sort(bases, bases + b);
  sort(a, a + s);
  long long cuind = 0, cug = 0;
  for (int i = 0; i < s; i++) {
    while (cuind < b && a[i].first >= bases[cuind].first) {
      cug += bases[cuind].second;
      cuind++;
    }
    ans[a[i].second] = cug;
  }
  for (int i = 0; i < s; i++) cout << ans[i] << " ";
}
