#include <bits/stdc++.h>
using namespace std;
bool primeCheck(long long n) {
  if (n % 2 == 0) return false;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}
long long power(long long n, long long p) {
  if (p == 0) return 1;
  if (p == 1) return n;
  if (p % 2)
    return power(n, p - 1) * n;
  else {
    long long x = power(n, p / 2);
    return x * x;
  }
}
string twostringdigitsum(string a, string b) {
  string s = "";
  while (a.size() < b.size()) {
    a = '0' + a;
  }
  while (a.size() > b.size()) {
    b = '0' + b;
  }
  long long c = 0;
  for (long long i = a.size() - 1; i >= 0; i--) {
    c += (a[i] - '0') + (b[i] - '0');
    s = char((c % 10) + '0') + s;
    c /= 10;
  }
  while (c > 0) {
    s = char((c % 10) + '0') + s;
    c /= 10;
  }
  return s;
}
long long stringdigitsum(string digits) {
  long long num, total = 0;
  for (int i = 0; i < digits.length(); i++) {
    num = digits.at(i) - '0';
    assert(0 <= num && num <= 9);
    total += num;
  }
  return total;
}
long long integerdigitsum(long long n) {
  long long sum = 0;
  while (1) {
    if (n < 10) {
      sum += n;
      break;
    } else {
      sum += n % 10;
      n /= 10;
    }
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, m, i, x, y;
  string s;
  cin >> n >> m;
  vector<long long> ar(n), v1(m), v2(m);
  vector<pair<long long, long long>> v;
  for (i = 0; i < n; i++) cin >> ar[i];
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    v1[i] = x;
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end());
  sort(v1.begin(), v1.end());
  for (i = 1; i < m; i++) v[i].second += v[i - 1].second;
  for (i = 0; i < n; i++) {
    auto it = upper_bound(v1.begin(), v1.end(), ar[i]);
    long long k = it - v1.begin();
    if (k == 0)
      cout << "0" << ' ';
    else
      cout << v[k - 1].second << ' ';
  }
  return 0;
}
