#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000009;
const int maxn = 1e5 + 100;
const double pi = acos(-1);
int s[maxn];
struct node {
  long long val, num, sum;
  node() {}
  node(int k) : val(k) {}
  bool operator<(const node a) const { return val <= a.val; }
};
node k[maxn];
int cmp(node a, node b) {
  if (a.val == b.val) return a.num < b.num;
  return a.val < b.val;
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> s[i];
  for (int i = 1; i <= m; ++i) cin >> k[i].val >> k[i].num, k[i].sum = k[i].num;
  sort(k + 1, k + 1 + m, cmp);
  for (int i = 1; i <= m; ++i) k[i].sum += k[i - 1].sum;
  for (int i = 1; i <= n; ++i) {
    long long x = lower_bound(k + 1, k + 1 + m, node(s[i])) - k;
    cout << k[x - 1].sum;
    if (i == n)
      cout << endl;
    else
      cout << " ";
  }
  return 0;
}
