#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
long long int add(long long int a, long long int b) {
  return ((a % 1000000007) + (b % 1000000007)) % 1000000007;
}
long long int sub(long long int a, long long int b) {
  return ((a % 1000000007) - (b % 1000000007) + 1000000007) % 1000000007;
}
long long int mul(long long int a, long long int b) {
  return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << "\n";
  err(++it, args...);
}
long long int *getfactorial() {
  int m = 1e6;
  long long int *fact = new long long int[m + 1];
  fact[0] = 1;
  for (int i = (1); i <= (m); i++) {
    fact[i] = (fact[i - 1] * i) % 1000000007;
  }
  return fact;
}
vector<long long int> *getfactors() {
  int n = 2e5;
  vector<long long int> *factors = new vector<long long int>[n + 5];
  for (int i = (1); i <= (n); i++) {
    for (int j = i; j <= n; j += i) {
      factors[j].push_back(i);
    }
  }
  return factors;
}
long long int power(long long int a, long long int b,
                    long long int m = 1000000007) {
  if (b == 0) return 1;
  long long int smallans = power(a, b / 2, m);
  long long int ans = (smallans * smallans) % m;
  if (b % 2 == 1) {
    ans = (ans * a) % m;
  }
  return ans;
}
bool *isprime() {
  int m = 1e6;
  bool *p = new bool[m + 5];
  for (int i = (0); i <= (m); i++) p[i] = true;
  p[0] = false;
  p[1] = false;
  for (int i = (2); i <= (sqrt(m)); i++) {
    for (int j = 2 * i; j <= m; j += i) {
      p[j] = false;
    }
  }
  return p;
}
long long int nCr(long long int n, long long int r, int m = 1000000007) {
  if (n < r) return 0;
  long long int *fac = getfactorial();
  long long int ans = fac[n];
  ans = (ans * power(fac[n - r], m - 2)) % m;
  ans = (ans * power(fac[r], m - 2)) % m;
  return ans;
}
bool intersect(pair<long long int, long long int> a,
               pair<long long int, long long int> b) {
  if (a.second > b.first) return true;
  return false;
}
string s;
int n;
int check(int i) {
  if (i + 2 >= n) return 0;
  if (s[i] == s[i + 1] and s[i] == s[i + 2]) return 1;
  if (i + 3 >= n) return 0;
  if (s[i] == s[i + 1] and s[i + 2] == s[i + 3]) return 2;
  return 0;
}
int totalcheck() {
  int ans = -1, m = INT_MAX;
  int x = ceil((long double)n / 2);
  for (int i = (0); i <= (n - 1); i++) {
    if (check(i) != 0) {
      if (m > abs(x - i)) {
        m = abs(x - i);
        ans = i;
      }
    }
  }
  return ans;
}
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, b;
  cin >> n >> b;
  long long int a[n + 1];
  a[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  ;
  pair<long long int, long long int> p[b + 1];
  for (int i = (0); i <= (b - 1); i++) cin >> p[i].first >> p[i].second;
  sort(p, p + b, comp);
  long long int pref[b + 1];
  pref[0] = p[0].second;
  for (int i = (1); i <= (b - 1); i++) pref[i] = pref[i - 1] + p[i].second;
  pref[b] = pref[b - 1];
  for (int i = (1); i <= (n); i++) {
    pair<long long int, long long int> x = {a[i], 0};
    long long int idx = lower_bound(p, p + b, x) - p;
    if (idx > b) idx--;
    if (p[idx].first > a[i]) idx--;
    if (idx < 0)
      cout << 0 << "\n";
    else
      cout << pref[idx] << " ";
  }
  cout << "\n";
}
