#include <bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 3e5 + 7;
const int mod = 1e9 + 7;
int s, b;
int a[maxn];
int pre[maxn];
pair<int, int> base[maxn];
int tmp[maxn];
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", &base[i].first, &base[i].second);
  sort(base + 1, base + 1 + b);
  for (int i = 1; i <= b; i++) pre[i] = pre[i - 1] + base[i].second;
  for (int i = 1; i <= b; i++) tmp[i] = base[i].first;
  for (int i = 1; i <= s; i++) {
    int p = upper_bound(tmp + 1, tmp + 1 + b, a[i]) - tmp;
    p--;
    printf("%d ", pre[p]);
  }
  printf("\n");
  return 0;
}
