#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 1000000007;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int pow(int a, int b, int c) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
pair<int, int> a[100010], b[100010];
int ans[100010];
int main() {
  int T, ca = 0, k, i, j, n, m = 0, K;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i].first), a[i].second = i;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &b[i].first, &b[i].second);
  }
  sort(a, a + n);
  sort(b, b + m);
  k = 0;
  K = 0;
  for (int i = 0; i < n; i++) {
    while (k < m && b[k].first <= a[i].first) {
      K += b[k++].second;
    }
    ans[a[i].second] = K;
  }
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
  puts("");
}
