#include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 123;
int const INF = 1e9 + 123;
int n, m, l[N], r[N], t[N];
int tree[N * 4];
long long ans[N];
int q[N];
map<int, int> h;
vector<int> x, g;
int tsz;
void hashit() {
  for (int i = 0; i < m; ++i) {
    for (int j = -1; j < 2; ++j) {
      x.push_back(l[i] + j);
      x.push_back(r[i] + j);
    }
  }
  sort(x.begin(), x.end());
  for (int i = 0; i < (int)(x.size()); ++i) {
    if (!i || x[i] != x[i - 1]) {
      g.push_back(x[i]);
      int v = (int)(h.size());
      h[x[i]] = v;
    }
  }
  x = g;
}
void upd(int v, int tl, int tr, int l, int r, int val) {
  if (tl > r || l > tr) return;
  if (l <= tl && tr <= r) {
    tree[v] = min(tree[v], val);
    return;
  }
  int tm = (tl + tr) / 2;
  upd(v * 2 + 1, tl, tm, l, r, val);
  upd(v * 2 + 2, tm + 1, tr, l, r, val);
}
void build() {
  tsz = (int)(x.size());
  for (int i = 0; i < N * 4; ++i) tree[i] = INF;
  for (int i = 0; i < m; ++i) {
    int l = h[::l[i]];
    int r = h[::r[i]];
    upd(0, 0, tsz - 1, l, r, t[i]);
  }
}
int getmin(int v, int tl, int tr, int p) {
  if (tl == tr) return tree[v];
  int res = tree[v];
  int tm = (tl + tr) / 2;
  if (p <= tm)
    res = min(res, getmin(v * 2 + 1, tl, tm, p));
  else
    res = min(res, getmin(v * 2 + 2, tm + 1, tr, p));
  return res;
}
int a[N];
int nl[N], nr[N], nt[N];
int ce;
void buildevents() {
  int lp;
  int lv = INF;
  for (int i = 0; i < tsz; ++i) {
    if (a[i] == INF) {
      if (lv != INF) {
        nl[ce] = lp;
        nr[ce] = i - 1;
        nt[ce] = lv;
        ++ce;
        lv = INF;
      }
    } else {
      if (lv == INF) {
        lv = a[i];
        lp = i;
      } else {
        if (lv != a[i]) {
          nl[ce] = lp;
          nr[ce] = i - 1;
          nt[ce] = lv;
          ++ce;
          lv = a[i];
          lp = i;
        }
      }
    }
  }
}
int getpos(int id, int t) { return t - q[id]; }
int getright(int v, int t) {
  int l = -1;
  int r = n;
  while (r - l > 1) {
    int h = (l + r) / 2;
    int x = getpos(h, t);
    if (x >= v)
      l = h;
    else
      r = h;
  }
  return l;
}
int getleft(int v, int t) {
  int l = -1;
  int r = n;
  while (r - l > 1) {
    int h = (l + r) / 2;
    int x = getpos(h, t);
    if (x <= v)
      r = h;
    else
      l = h;
  }
  return r;
}
long long F[N], FO[N];
void updf(long long *F, int x, int v) {
  while (x < n) {
    F[x] += v;
    x |= (x + 1);
  }
}
void updf(long long *F, int l, int r, int v) {
  if (l > r) return;
  updf(F, l, v);
  updf(F, r + 1, -v);
}
long long getf(long long *F, int x) {
  long long res = 0;
  while (x >= 0) {
    res += F[x];
    x = (x & (x + 1)) - 1;
  }
  return res;
}
void procevent(int l, int r, int t) {
  int le = getleft(r, t);
  int ri = getright(l, t);
  int len = r - l + 1;
  updf(F, ri + 1, len);
  updf(FO, le, ri, 1);
  updf(F, le, ri, r - t + 1);
}
void solve() {
  for (int i = 0; i < m; ++i) r[i] -= 1;
  hashit();
  build();
  for (int i = 0; i < tsz; ++i) a[i] = getmin(0, 0, tsz - 1, i);
  buildevents();
  for (int i = 0; i < ce; ++i) {
    procevent(x[nl[i]], x[nr[i]], nt[i]);
  }
  for (int i = 0; i < n; ++i) {
    ans[i] = getf(F, i);
    ans[i] += getf(FO, i) * 1LL * q[i];
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) scanf("%d %d %d", &l[i], &r[i], &t[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &q[i]);
  solve();
  for (int i = 0; i < n; ++i) printf("%lld\n", ans[i]);
  return 0;
}
