#include <bits/stdc++.h>
void build(const std::vector<std::pair<int, int>>& values,
           std::vector<int64_t>& seg, int node, int start, int end) {
  if (start == end) {
    seg[node] = values[start].second;
  } else if (start < end) {
    int mid = (start + end) / 2;
    build(values, seg, 2 * node, start, mid);
    build(values, seg, 2 * node + 1, mid + 1, end);
    seg[node] = seg[2 * node] + seg[2 * node + 1];
  }
}
int64_t query(const std::vector<int64_t>& seg, int node, int start, int end,
              int l, int r) {
  if (r < start || end < l) {
    return 0;
  }
  if (l <= start && end <= r) {
    return seg[node];
  }
  int mid = (start + end) / 2;
  int64_t p1 = query(seg, 2 * node, start, mid, l, r);
  int64_t p2 = query(seg, 2 * node + 1, mid + 1, end, l, r);
  return (p1 + p2);
}
int getUpperBound(const std::vector<std::pair<int, int>>& values, int v,
                  int start, int end) {
  int l = start;
  int r = end;
  while (l < r) {
    int m = (l + r + 1) / 2;
    if (v >= values[m].first) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  if (values[r].first <= v) return r;
  return -1;
}
int main() {
  std::ios::sync_with_stdio(false);
  int s, b;
  std::cin >> s >> b;
  std::vector<int> a(s, 0);
  for (int i = 0; i < s; ++i) std::cin >> a[i];
  std::vector<std::pair<int, int>> dg(b, {0, 0});
  for (int i = 0; i < b; ++i) std::cin >> dg[i].first >> dg[i].second;
  std::sort(dg.begin(), dg.end());
  std::vector<int64_t> seg(4 * b, 0);
  build(dg, seg, 1, 0, b - 1);
  for (int i = 0; i < s; ++i) {
    auto offset = getUpperBound(dg, a[i], 0, b - 1);
    if (offset != -1) {
      std::cout << query(seg, 1, 0, b - 1, 0, offset) << ' ';
    } else {
      std::cout << 0 << ' ';
    }
  }
  return 0;
}
