#include <bits/stdc++.h>
using namespace std;
long long fastpow(long long base, long long power, long long M) {
  if (power == 1) return base;
  long long val = fastpow(base, power / 2, M);
  return (power % 2 == 0) ? (val * val) % M : (((val * val) % M) * base) % M;
}
inline void debugMode() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
const int N = 1e5 + 1;
const int MOD = 1e9 + 7;
int main() {
  debugMode();
  int s, b;
  cin >> s >> b;
  int arr[s];
  for (int i = 0; i < s; i++) cin >> arr[i];
  vector<pair<int, int>> base(b);
  for (int i = 0; i < b; i++) cin >> base[i].first >> base[i].second;
  sort((base).begin(), (base).end());
  for (int i = 1; i < b; i++) base[i].second += base[i - 1].second;
  for (int i = 0; i < s; i++) {
    int left = -1, right = b;
    while (left + 1 < right) {
      int mid = (left + right) / 2;
      if (base[mid].first <= arr[i])
        left = mid;
      else
        right = mid;
    }
    if (left == -1)
      cout << 0 << " ";
    else
      cout << base[left].second << " ";
  }
  return 0;
}
