#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
int n, m;
pair<int, pair<int, int> > wall[100005];
pair<int, pair<int, int> > wall2[500005];
int wzip[200005], wn;
set<pair<int, int> > s;
pair<int, int> toins[200005], toers[200005];
int q[100005];
long long int imos[100005];
int add[100005];
int ans[100005];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &wall[i].second.first, &wall[i].second.second,
          &wall[i].first);
  }
  for (int i = 0; i < n; ++i) scanf("%d", &q[i]), q[i] *= -1;
  reverse(q, q + n);
  sort(wall, wall + m);
  int m2 = 0;
  s.insert(make_pair(-1, 1e9 + 10));
  for (int i = 0; i < m; ++i) {
    int cnt = 0, cnt2 = 0;
    pair<int, int> r = wall[i].second;
    set<pair<int, int> >::iterator it = s.lower_bound(r);
    if (s.begin() != it) --it;
    while (it != s.end()) {
      if (r.second <= it->first) break;
      if (it->first < r.second && r.first < it->second) {
        wall2[m2++] = make_pair(
            wall[i].first,
            make_pair(max(it->first, r.first), min(it->second, r.second)));
        if (it->first < r.first) toins[cnt++] = make_pair(it->first, r.first);
        if (r.second < it->second)
          toins[cnt++] = make_pair(r.second, it->second);
        toers[cnt2++] = *it;
      }
      ++it;
    }
    for (int hoge = 0; hoge < cnt2; ++hoge) s.erase(toers[hoge]);
    for (int hoge = 0; hoge < cnt; ++hoge) s.insert(toins[hoge]);
  }
  for (int i = 0; i < m2; ++i) {
    int t = wall2[i].first;
    pair<int, int> r = wall2[i].second;
    int lb = -1, ub = n;
    while (ub - lb > 1) {
      int md = (lb + ub) >> 1;
      if (q[md] <= r.first - t)
        lb = md;
      else
        ub = md;
    }
    int b = lb + 1;
    lb = -1, ub = n;
    while (ub - lb > 1) {
      int md = (lb + ub) >> 1;
      if (q[md] >= r.second - t)
        ub = md;
      else
        lb = md;
    }
    int a = ub;
    imos[0] += r.second - r.first;
    imos[a] -= r.second - r.first;
    int bot = r.first - t;
    imos[b] += bot;
    imos[a] -= bot;
    add[b]++;
    add[a]--;
  }
  for (int i = 0; i < n; ++i) imos[i + 1] += imos[i];
  for (int i = 0; i < n; ++i) add[i + 1] += add[i];
  for (int i = 0; i < n; ++i) ans[i] = imos[i] - add[i] * q[i];
  reverse(ans, ans + n);
  for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}
