#include <bits/stdc++.h>
using namespace std;
map<string, long long int> month;
void Month() {
  month["January"] = 1, month["February"] = 2, month["March"] = 3,
  month["April"] = 4, month["May"] = 5, month["June"] = 6;
  month["July"] = 7, month["August"] = 8, month["September"] = 9,
  month["October"] = 10, month["November"] = 11, month["December"] = 12;
}
long long int A[10000000 + 7];
long long int B[10000000 + 7];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<long long int> v, help;
  map<long long int, long long int> mp;
  long long int n, k, a, b, sum = 0;
  cin >> n >> k;
  for (long long int i = 0; i < n; i++) cin >> A[i];
  for (long long int i = 0; i < k; i++)
    cin >> a >> b, v.push_back(a), mp[a] += b;
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (long long int i = 0; i < v.size(); i++) {
    sum += mp[v[i]];
    help.push_back(sum);
  }
  for (long long int i = 0; i < n; i++) {
    long long int val = A[i];
    long long int lb = lower_bound(v.begin(), v.end(), val) - v.begin();
    if ((v[lb] != val) && lb == 0)
      cout << 0 << " ";
    else if (v[lb] != val)
      cout << help[lb - 1] << " ";
    else
      cout << help[lb] << " ";
  }
  return 0;
}
