#include <bits/stdc++.h>
using namespace std;
long long int powr(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  if (b % 2 == 0) {
    return powr(((a % 1000000007) * (a % 1000000007)) % 1000000007, b / 2);
  } else {
    if (b == 1) {
      return a;
    } else {
      return (a * powr(((a % 1000000007) * (a % 1000000007) % 1000000007),
                       (b - 1) / 2)) %
             1000000007;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long s, b;
  cin >> s >> b;
  long long a[s];
  long long u[b];
  for (long long i = 0; i < s; i++) {
    cin >> a[i];
  }
  vector<pair<long long, long long> > p;
  long long c, d;
  for (long long i = 0; i < b; i++) {
    cin >> c >> d;
    p.push_back({c, d});
    u[i] = c;
  }
  sort(p.begin(), p.end());
  sort(u, u + b);
  long long y = 0;
  long long sum[b];
  for (long long i = 0; i < b; i++) {
    y += p[i].second;
    sum[i] = y;
  }
  for (long long i = 0; i < s; i++) {
    pair<long long, long long> cur = {a[i], INT_MAX};
    auto idx = lower_bound(p.begin(), p.end(), cur);
    if (idx == p.begin()) {
      cout << 0 << " ";
      continue;
    }
    idx--;
    long long j = idx - p.begin();
    cout << sum[j] << " ";
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
