#include <bits/stdc++.h>
using namespace std;
void solve() {
  int t = 1;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int a[n];
    vector<pair<long long int, long long int>> b(m);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
      long long int c, d;
      cin >> c;
      cin >> d;
      b[i] = make_pair(c, d);
    }
    sort(b.begin(), b.end());
    for (int i = 1; i < m; i++) {
      b[i].second += b[i - 1].second;
    }
    for (int i = 0; i < n; i++) {
      pair<long long, long long> p = {a[i], 0};
      auto ans = upper_bound(b.begin(), b.end(), p);
      if (ans - b.begin() < m) {
        if (b[ans - b.begin()].first == a[i])
          cout << b[ans - b.begin()].second << endl;
        else if (ans - b.begin() - 1 >= 0)
          cout << b[ans - b.begin() - 1].second << endl;
        else
          cout << 0 << endl;
      } else
        cout << b[m - 1].second << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
