#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 1e5 + 5, START = 0, FINISH = 1;
class event {
 public:
  int x, t, type;
  bool operator<(event other) const { return x < other.x; }
};
int n, m, l, r, t, a[N];
vector<event> v;
multiset<int> s;
map<int, int> dp;
int main() {
  ios ::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> l >> r >> t;
    v.push_back((event){l + 1, t + 1, START});
    v.push_back((event){r + 1, t + 1, FINISH});
  }
  sort(v.begin(), v.end());
  int last = 0;
  for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++) {
    if (!s.empty()) {
      int down = last;
      int up = it->x - 1;
      int time = *s.begin();
      dp[time - up]++;
      dp[time - down + 1]--;
    }
    last = it->x;
    __typeof((v).begin()) temp_it = it;
    while (it != v.end() and it->x == temp_it->x) {
      if (it->type == START)
        s.insert(it->t);
      else
        s.erase(s.find(it->t));
      it++;
    }
    it--;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[a[i]] += 0;
  }
  int bef, befx, bef_old;
  for (__typeof((dp).begin()) it = (dp).begin(); it != (dp).end(); it++) {
    if (it != dp.begin()) it->second += bef;
    bef = it->second;
  }
  for (__typeof((dp).begin()) it = (dp).begin(); it != (dp).end(); it++) {
    int t = it->second;
    if (it != dp.begin()) it->second += bef_old * (it->first - befx - 1) + bef;
    befx = it->first;
    bef = it->second;
    bef_old = t;
  }
  for (int i = 1; i <= n; i++) cout << dp[a[i]] << '\n';
  return 0;
}
