#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, b;
  cin >> n >> b;
  vector<int> power(n);
  for (int i = 0; i < n; i++) cin >> power[i];
  vector<pair<int, long long>> defense(b + 1);
  for (int i = 1; i < b + 1; i++) cin >> defense[i].first >> defense[i].second;
  sort(defense.begin() + 1, defense.end());
  for (int i = 2; i < b + 1; i++) defense[i].second += defense[i - 1].second;
  for (int i = 0; i < n; i++) {
    int x = power[i];
    int low = 1, high = b;
    while (low < high) {
      int mid = low + (high - low) / 2;
      if (defense[mid].first < x)
        low = mid + 1;
      else
        high = mid;
    }
    if (low == 0)
      cout << 0;
    else {
      if (x < defense[low].first) low--;
      cout << defense[low].second;
    }
    cout << " ";
  }
}
