#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
struct segm {
  int l, r;
  int timeAppear;
  segm() {}
  segm(int _l) : l(_l) {}
  segm(int _l, int _r, int _timeAppear)
      : l(_l), r(_r), timeAppear(_timeAppear) {}
  void read() { assert(scanf("%d%d%d", &l, &r, &timeAppear) == 3); }
  inline bool operator<(const segm &s) const {
    return timeAppear < s.timeAppear;
  }
};
struct segmCompare {
  inline bool operator()(const segm &s1, const segm &s2) const {
    return s1.l < s2.l;
  }
};
const int maxn = (int)1e5;
segm ss0[maxn], ss[2 * maxn];
pair<int, int> qs[maxn];
int plusConstant[maxn + 1], plusX[maxn + 1];
int ans[maxn];
int main() {
  srand(rdtsc());
  int n, m;
  while (scanf("%d%d", &n, &m) >= 1) {
    for (int i = 0; i < m; i++) ss0[i].read();
    for (int i = 0; i < n; i++)
      scanf("%d", &qs[i].first), qs[i].first = -qs[i].first, qs[i].second = i;
    sort(ss0, ss0 + m);
    set<segm, segmCompare> S;
    int newm = 0;
    for (int i = 0; i < m; i++) {
      segm cur = ss0[i];
      set<segm, segmCompare>::iterator iter;
      iter = S.upper_bound(cur);
      if (iter != S.begin()) {
        iter--;
        cur.l = max(cur.l, iter->r);
      }
      iter = S.lower_bound(cur);
      int newm0 = newm;
      while (cur.l < cur.r) {
        segm toadd(cur.l, min(cur.r, iter == S.end() ? ((int)1e9) : iter->l),
                   cur.timeAppear);
        if (toadd.r - toadd.l > 0) {
          assert(newm < 2 * m - 1);
          ss[newm++] = toadd;
        }
        cur.l = max(cur.l, iter == S.end() ? ((int)1e9) : iter->r);
        if (iter != S.end()) iter++;
      }
      for (int j = newm0; j < newm; j++) {
        segm cur = ss[j];
        set<segm, segmCompare>::iterator iter = S.lower_bound(cur);
        if (iter != S.end() && iter->l == cur.r) {
          cur.r = iter->r;
          S.erase(iter);
        }
        iter = S.lower_bound(cur);
        if (iter != S.begin()) {
          iter--;
          if (iter->r == cur.l) {
            cur.l = iter->l;
            S.erase(iter);
          }
        }
        S.insert(cur);
      }
    }
    m = newm;
    sort(qs, qs + n);
    memset(plusX, 0, sizeof(plusX[0]) * (n + 1));
    memset(plusConstant, 0, sizeof(plusConstant[0]) * (n + 1));
    for (int i = 0; i < m; i++) {
      segm cur = ss[i];
      int posr =
          lower_bound(qs, qs + n, make_pair(cur.r - cur.timeAppear, -1)) - qs;
      int posl =
          lower_bound(qs, qs + n, make_pair(cur.l - cur.timeAppear, -1)) - qs;
      plusConstant[posr] += cur.r - cur.timeAppear,
          plusConstant[posl] -= cur.l - cur.timeAppear;
      plusX[posr]--, plusX[posl]++;
    }
    for (int i = n - 1; i >= 0; i--) {
      ans[qs[i].second] = plusX[i + 1] * qs[i].first + plusConstant[i + 1];
      plusX[i] += plusX[i + 1], plusConstant[i] += plusConstant[i + 1];
    }
    for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
  }
  return 0;
}
