#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
const int maxn = 2e5 + 5;
void input() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void Sieve(long long n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
long long pw(int x, unsigned int y, int p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = 1ll * (res * x) % p;
    y = y >> 1;
    x = (1ll * x * x) % p;
  }
  return res;
}
long long a[100005];
vector<pair<int, int> > v;
vector<int> v1;
vector<int> v2;
int main() {
  input();
  int second, b, d;
  cin >> second >> b;
  v.resize(b), v1.resize(b), v2.resize(b);
  for (int i = 0; i < int(second); i++) cin >> a[i];
  for (int i = 0; i < int(b); i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort((v).begin(), (v).end());
  for (int i = 0; i < int(b); i++) {
    v1[i] = v[i].first;
  }
  v2[0] = v[0].second;
  for (long long i = 1; i < b; i++) {
    v2[i] = v[i].second;
    v2[i] += v2[i - 1];
  }
  for (int i = 0; i < int(second); i++) {
    auto it = upper_bound((v1).begin(), (v1).end(), a[i]);
    if (it == v1.begin()) {
      cout << 0 << " ";
    } else {
      d = it - v1.begin();
      cout << v2[d - 1] << " ";
    }
  }
  return 0;
}
