#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
long long s, b, a[100005];
long long pref[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, ans = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<pair<long long, long long> > v(m);
  for (int i = 0; i < m; i++) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  vector<long long> v1(m);
  for (int i = 0; i < m; i++) v1[i] = v[i].first;
  long long sum[m + 1];
  sum[0] = 0;
  for (int i = 0; i < m; i++) sum[i + 1] = sum[i] + v[i].second;
  for (int i = 0; i < n; i++) {
    auto t = upper_bound(v1.begin(), v1.end(), a[i]) - v1.begin();
    cout << sum[t] << " ";
  }
  return 0;
}
