#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  vector<pair<long long int, pair<long long int, long long int>>> u(m);
  for (long long int i = 0; i < m; i++) {
    cin >> u[i].first >> u[i].second.first;
  }
  sort(u.begin(), u.end());
  long long int sum = 0;
  for (long long int i = 0; i < m; i++) {
    sum += u[i].second.first;
    u[i].second.second = sum;
  }
  vector<long long int> searchSpace;
  for (auto ele : u) searchSpace.push_back(ele.first);
  for (long long int i = 0; i < n; i++) {
    long long int ele =
        upper_bound(searchSpace.begin(), searchSpace.end(), v[i]) -
        searchSpace.begin();
    if (ele == m)
      cout << u[m - 1].second.second << " ";
    else {
      ele--;
      if (ele < 0)
        cout << "0 ";
      else
        cout << u[ele].second.second << " ";
    }
  }
  return 0;
}
