#include <bits/stdc++.h>
using namespace std;
struct ddddd {
  int d, g;
} t[100005];
int a[100005], sum[100005], num[100005];
bool cmp(ddddd x, ddddd y) { return x.d < y.d; }
int main() {
  int s, b;
  cin >> s >> b;
  for (int i = 1; i <= s; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= b; i++) {
    cin >> t[i].d >> t[i].g;
    num[i] = t[i].d;
  }
  sort(t + 1, t + 1 + b, cmp);
  sort(num + 1, num + 1 + b);
  for (int i = 1; i <= b; i++) {
    sum[i] = sum[i - 1] + t[i].g;
  }
  for (int i = 1; i <= s; i++) {
    cout << sum[upper_bound(num + 1, num + b + 1, a[i]) - num - 1] << " ";
  }
}
