#include <bits/stdc++.h>
const long long MAX_N = 3e5 + 100;
const long long MAX_E = 4500000 + 100;
const long long MOD = 1e9 + 7;
using namespace std;
vector<pair<int, pair<int, int>>> qs;
vector<int> ps;
int seg[MAX_E];
int mg[MAX_E];
int mv[MAX_E];
unordered_map<int, int> mp;
int n, q;
int y;
void build(int k) {
  if (k >= y) {
    mg[k] = seg[k];
    return;
  }
  build(k * 2);
  build(k * 2 + 1);
  seg[k] = seg[k * 2] + seg[k * 2 + 1];
  mg[k] = seg[k];
}
void down(int k, int l, int r) {
  if (mv[k * 2] != mv[k]) {
    if (mv[k] == 1)
      seg[k * 2] -= seg[k * 2];
    else
      seg[k * 2] += mg[k * 2] - seg[k * 2];
  }
  if (mv[k * 2 + 1] != mv[k]) {
    if (mv[k] == 1)
      seg[k * 2 + 1] -= seg[k * 2 + 1];
    else
      seg[k * 2 + 1] += mg[k * 2 + 1] - seg[k * 2 + 1];
  }
  mv[k * 2] = mv[k];
  mv[k * 2 + 1] = mv[k];
  mv[k] = 0;
}
void change(int l, int r, int a, int b, int k, int x) {
  if (r < a or b < l) return;
  if (a <= l and r <= b) {
    if (mv[k] == x) return;
    mv[k] = x;
    if (x == 1) {
      seg[k] = 0;
    } else {
      seg[k] = mg[k];
    }
    return;
  }
  if (mv[k]) down(k, l, r);
  int mid = (l + r) / 2;
  change(l, mid, a, b, k * 2, x);
  change(mid + 1, r, a, b, k * 2 + 1, x);
  seg[k] = seg[k * 2] + seg[k * 2 + 1];
}
int main() {
  cin >> n;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int k, l, r;
    scanf("%d%d%d", &l, &r, &k);
    qs.push_back({k, {l, r}});
    ps.push_back(l);
    ps.push_back(r);
  }
  sort(ps.begin(), ps.end());
  int last = 0;
  int m = 0;
  for (int i = 0; i < ps.size(); ++i) {
    if (ps[i] == last) continue;
    if (ps[i] - last == 1) {
      last = ps[i];
      m++;
      continue;
    }
    last = ps[i];
    m += 2;
  }
  if (last != n) m++;
  last = 0;
  y = (1ll << ((int)ceil(log2(m))));
  int pt = 0;
  for (int i = 0; i < ps.size(); ++i) {
    if (ps[i] == last) continue;
    if (ps[i] - last == 1) {
      last = ps[i];
      seg[pt + y] = 1;
      mp[ps[i]] = pt;
      pt++;
      continue;
    }
    seg[pt + y] = ps[i] - last - 1;
    seg[pt + 1 + y] = 1;
    pt++;
    mp[ps[i]] = pt;
    pt++;
    last = ps[i];
  }
  if (last != n) seg[pt + y] = n - last;
  build(1);
  for (int i = 0; i < q; ++i) {
    change(0, y - 1, mp[qs[i].second.first], mp[qs[i].second.second], 1,
           qs[i].first);
    printf("%d\n", seg[1]);
  }
  return 0;
}
