#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
int main() {
  int s, b;
  long long ad, hp, my, gm;
  cin >> s >> b;
  vector<pair<int, int> > bases(b);
  vector<int> ships(s);
  for (int i = 0; i < s; i++) {
    cin >> ad;
    ships[i] = ad;
  }
  for (int i = 0; i < b; i++) {
    cin >> hp >> my;
    bases[i] = pair<int, int>(hp, my);
  }
  sort(bases.begin(), bases.end(), cmp);
  for (int i = 0; i < s; i++) {
    gm = 0;
    for (int j = 0; j < b; j++) {
      if (ships[i] >= bases[j].first)
        gm += bases[j].second;
      else
        break;
    }
    if (i != 0) cout << ' ';
    cout << gm;
  }
}
