#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 1e5 + 9;
vector<pair<int, ll>> vc;
int arr[MAX_N];
int bs(int n) {
  int s = 0, e = vc.size() - 1;
  while (s < e) {
    int md = s + (e - s + 1) / 2;
    if (vc[md].first <= n)
      s = md;
    else
      e = md - 1;
  }
  if (vc[s].first > n) return 0;
  return vc[s].second;
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int s, b;
  cin >> s >> b;
  for (int i = 0; i < s; i++) cin >> arr[i];
  vc.resize(b);
  for (auto &i : vc) cin >> i.first >> i.second;
  sort(vc.begin(), vc.end());
  for (int i = 1; i < vc.size(); i++) vc[i].second += vc[i - 1].second;
  for (int i = 0; i < s; i++) {
    cout << bs(arr[i]) << ' ';
  }
}
