#include <bits/stdc++.h>
using namespace std;
long long const MX = 1e5 + 10;
long long const INF = 1e9;
pair<int, int> a1[MX];
pair<int, int> a2[MX];
long long res[MX];
bool cmp(pair<int, int> x, pair<int, int> y) { return x.first < y.first; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int s, b;
  cin >> s >> b;
  for (int i = 0; i < s; i++) {
    int x;
    cin >> x;
    a1[i].first = x;
    a1[i].second = i;
  }
  for (int i = 0; i < b; i++) {
    int x, y;
    cin >> x >> y;
    a2[i].first = x;
    a2[i].second = y;
  }
  sort(a1, a1 + s, cmp);
  sort(a2, a2 + b, cmp);
  int i = 0, j = 0;
  long long sum = 0;
  while (i < s) {
    while (a2[j].first <= a1[i].first && j < b) {
      sum += a2[j].second;
      j++;
    }
    res[a1[i].second] = sum;
    i++;
  }
  for (int i = 0; i < s; i++) cout << res[i] << " ";
  return 0;
}
