#include <bits/stdc++.h>
using namespace std;
struct Interval {
  int start, end;
};
bool compare(Interval i1, Interval i2) { return (i1.start < i2.start); }
vector<long long int> factors;
void Divisors(long long int n) {
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        factors.push_back(i);
      else {
        factors.push_back(i);
        factors.push_back(n / i);
      }
    }
  }
}
long long int coun[100005] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int second, b;
  cin >> second >> b;
  long long int ships[second];
  for (long long int i = 0; i < (second); ++i) cin >> ships[i];
  vector<pair<long long, long long> > base;
  vector<long long int> v;
  for (long long int i = 0; i < (b); ++i) {
    long long int d, g;
    cin >> d >> g;
    base.push_back(make_pair(d, g));
    v.push_back(d);
  }
  sort(v.begin(), v.end());
  sort(base.begin(), base.end());
  coun[0] = base[0].second;
  for (int i = 1; i <= (base.size() - 1); ++i) {
    coun[i] = coun[i - 1] + base[i].second;
  }
  for (long long int i = 0; i < (second); ++i) {
    if (ships[i] < base[0].first) {
      cout << 0 << " ";
      continue;
    }
    vector<long long int>::iterator it =
        upper_bound(v.begin(), v.end(), ships[i]);
    long long int len = it - v.begin();
    cout << coun[len - 1] << " ";
  }
  return 0;
}
