#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long INF = 1e18L + 7;
template <class n, class second>
ostream &operator<<(ostream &p, pair<n, second> x) {
  return p << "<" << x.first << ", " << x.second << ">";
}
template <class n>
auto operator<<(ostream &p, n y) ->
    typename enable_if<!is_same<n, string>::value,
                       decltype(y.begin(), p)>::type {
  int o = 0;
  p << "{";
  for (auto c : y) {
    if (o++) p << ", ";
    p << c;
  }
  return p << "}";
}
void dor() { cerr << '\n'; }
template <class n, class... second>
void dor(n p, second... y) {
  cerr << p << " ";
  dor(y...);
}
template <class n, class second>
void mini(n &p, second y) {
  if (p > y) p = y;
}
template <class n, class second>
void maxi(n &p, second y) {
  if (p < y) p = y;
}
const long long N = 1e5 + 7;
long long second, b;
long long a[N];
vector<pair<long long, long long> > bases;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> second >> b;
  for (long long i = 1; i <= second; ++i) {
    cin >> a[i];
  }
  for (long long i = 1; i <= b; ++i) {
    long long d, g;
    cin >> d >> g;
    bases.emplace_back(d, g);
  }
  sort((bases).begin(), (bases).end());
  for (long long i = 0; i + 1 < (long long)(bases).size(); ++i) {
    bases[i + 1].second += bases[i].second;
  }
  for (long long i = 1; i <= second; ++i) {
    long long ind =
        upper_bound((bases).begin(), (bases).end(), make_pair(a[i], INF)) -
        bases.begin() - 1;
    if (ind == -1)
      cout << 0 << " ";
    else
      cout << bases[ind].second << " ";
  }
}
