#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, b;
  cin >> n >> b;
  long long int a[n], i, j, k, l, t1, t2, sum = 0, ad[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    ad[i] = a[i];
  }
  vector<pair<long long int, long long int>> v;
  map<long long int, long long int> mp;
  for (i = 0; i < b; i++) {
    cin >> t1 >> t2;
    v.push_back(make_pair(t1, t2));
  }
  sort(v.begin(), v.end());
  sort(a, a + n);
  i = j = sum = 0;
  for (i = 0; i < n; i++) {
    while (a[i] >= v[j].first && j < b) {
      sum = sum + v[j].second;
      j++;
    }
    mp[a[i]] = sum;
  }
  for (i = 0; i < n; i++) {
    cout << mp[ad[i]] << " ";
  }
}
