#include <bits/stdc++.h>
using namespace std;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
struct ship {
  i64 a;
};
struct base {
  i64 d;
  i64 g;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 s, b;
  cin >> s >> b;
  vector<ship> ships(s);
  for (decltype(s) i = 0; i < (s); i++) cin >> ships[i].a;
  vector<base> bases(b);
  for (decltype(b) i = 0; i < (b); i++) cin >> bases[i].d >> bases[i].g;
  sort(bases.begin(), bases.end(),
       [](const base& a, const base& b) { return a.d < b.d; });
  for (decltype(b) i = 0; i < (b); i++) {
    if (i != 0) bases[i].g += bases[i - 1].g;
  }
  for (decltype(s) i = 0; i < (s); i++) {
    i64 atk = ships[i].a;
    if (atk < bases[0].d) {
      if (i != 0) cout << ' ';
      cout << 0;
      continue;
    }
    i64 l = 0, r = b - 1;
    while (l < r) {
      i64 mid = l + (r - l) / 2;
      const base& m = bases[mid];
      if (m.d <= atk) {
        if (mid != b - 1 && bases[mid + 1].d <= atk) {
          l = mid + 1;
        } else {
          l = r = mid;
        }
      } else {
        r = mid - 1;
      }
    }
    if (i != 0) cout << ' ';
    cout << bases[l].g;
  }
  cout << '\n';
  return 0;
}
