#include <bits/stdc++.h>
using namespace std;
const double pi = atan2(0.0, -1.0);
class Global {
 public:
  int bin_search(const vector<pair<int, int>>& mas, int x) {
    size_t n = mas.size();
    int middle, left, right;
    int answer;
    left = 0, right = n;
    while (right - left > 1) {
      middle = (right - left) / 2 + left;
      if (mas[middle].first > x)
        right = middle;
      else
        left = middle;
    }
    answer = left;
    return answer;
  }
  int i, j, n, m, answer;
  void solve() {
    cin >> n >> m;
    vector<int> a(n), sum(m);
    vector<pair<int, int>> b(m);
    for (auto& it : a) cin >> it;
    for (auto& it : b) cin >> it.first >> it.second;
    sort(b.begin(), b.end());
    for (i = 0; i < m; ++i) {
      if (i) sum[i] = sum[i - 1];
      sum[i] += b[i].second;
    }
    for (const auto& it : a) {
      i = bin_search(b, it);
      if (b[i].first > it)
        cout << "0 ";
      else
        cout << sum[i] << " ";
    }
  }
  void head() {
    int t = 1;
    for (; t--;) {
      solve();
    }
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<Global> global;
  global.clear();
  global.resize(1);
  global[0].head();
}
