#include <bits/stdc++.h>
using namespace std;
int s, b;
int a[100001];
struct RA {
  int d, g;
} rebel[100001];
bool temp(RA x, RA y) { return x.d < y.d; }
long long ans;
int main() {
  scanf("%d%d", &s, &b);
  for (int i = 1; i <= s; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= b; i++) scanf("%d%d", &rebel[i].d, &rebel[i].g);
  sort(rebel + 1, rebel + b + 1, temp);
  for (int i = 1; i <= s; i++) {
    ans = 0;
    for (int j = 1; j <= b; j++) {
      if (a[i] >= rebel[j].d)
        ans += rebel[j].g;
      else
        break;
    }
    printf("%I64d ", ans);
  }
}
