#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100, INF = 2000000000;
int BASE;
long long lin[1 << 19], sum[1 << 19];
void add(long long *tab, int a, int b, int x, int y, int p, long long v) {
  if (a == x && b == y) {
    tab[p] += v;
    return;
  }
  int mid = (x + y) / 2;
  if (a > mid) {
    add(tab, a, b, mid + 1, y, 2 * p + 1, v);
  } else if (b <= mid) {
    add(tab, a, b, x, mid, 2 * p, v);
  } else {
    add(tab, a, mid, x, mid, 2 * p, v);
    add(tab, mid + 1, b, mid + 1, y, 2 * p + 1, v);
  }
}
long long get(long long *tab, int a) {
  a += BASE;
  long long r = 0;
  while (a > 0) {
    r += tab[a];
    a >>= 1;
  }
  return r;
}
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<pair<int, int> > E;
  for (int i = 0; i < (m); ++i) {
    int l, r, t;
    scanf("%d%d%d", &l, &r, &t);
    E.push_back(make_pair(l, t));
    E.push_back(make_pair(r, t == 0 ? INF : -t));
  }
  sort((E).begin(), (E).end());
  vector<int> c;
  for (int i = 0; i < (n); ++i) {
    int a;
    scanf("%d", &a);
    c.push_back(a);
  }
  sort((c).begin(), (c).end());
  for (BASE = 1; BASE < n; BASE <<= 1)
    ;
  multiset<int> T;
  for (int i = 0; i < ((int)((E).size())); ++i) {
    if (i > 0 && E[i].first != E[i - 1].first && !T.empty()) {
      int tt = *T.begin();
      int r = E[i].first, l = E[i - 1].first;
      vector<int>::iterator it = upper_bound((c).begin(), (c).end(), tt - l);
      if (it != c.end()) {
        add(sum, it - c.begin(), n - 1, 0, BASE - 1, 1, r - l);
      }
      vector<int>::iterator jt = upper_bound((c).begin(), (c).end(), tt - r);
      if (jt != c.end() && it != jt) {
        add(sum, jt - c.begin(), it - c.begin() - 1, 0, BASE - 1, 1, r - tt);
        add(lin, jt - c.begin(), it - c.begin() - 1, 0, BASE - 1, 1, 1);
      }
    }
    if (E[i].second < 0 || E[i].second == INF) {
      multiset<int>::iterator it =
          T.find(E[i].second == INF ? 0 : -E[i].second);
      assert(it != T.end());
      T.erase(it);
    } else {
      T.insert(E[i].second);
    }
  }
  for (int i = 0; i < (n); ++i) {
    printf("%I64d\n", get(sum, i) + get(lin, i) * c[i]);
  }
  return 0;
}
