#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
inline int read() {
  int w = 1, a = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    a = a * 10 + ch - '0';
    ch = getchar();
  }
  return w * a;
}
struct TR {
  int lson, rson, lazy, sum;
} tr[15001000] = {0};
int n, q, tot = 1;
inline void pushup(int indx) {
  tr[indx].sum = tr[tr[indx].lson].sum + tr[tr[indx].rson].sum;
}
inline void pushdown(int indx, int ll, int rr) {
  if (~tr[indx].lazy) {
    int k = tr[indx].lazy, mid = (ll + rr) >> 1;
    if (!tr[indx].lson) tr[indx].lson = ++tot;
    tr[tr[indx].lson].sum = k * (mid - ll + 1);
    tr[tr[indx].lson].lazy = k;
    if (!tr[indx].rson) tr[indx].rson = ++tot;
    tr[tr[indx].rson].sum = k * (rr - mid);
    tr[tr[indx].rson].lazy = k;
    tr[indx].lazy = -1;
  }
}
inline void update(int indx, int ll, int rr, int L, int R, int val) {
  int l = ll, r = rr;
  if (L <= l && r <= R) {
    tr[indx].sum = (r - l + 1) * val;
    tr[indx].lazy = val;
    return;
  }
  pushdown(indx, ll, rr);
  int mid = (l + r) >> 1;
  if (L <= mid) {
    if (!tr[indx].lson) tr[indx].lson = ++tot;
    update(tr[indx].lson, ll, mid, L, R, val);
  }
  if (mid < R) {
    if (!tr[indx].rson) tr[indx].rson = ++tot;
    update(tr[indx].rson, mid + 1, rr, L, R, val);
  }
  pushup(indx);
}
inline void init() {
  for (int i = 0; i < 6000005; i++) tr[i].lazy = -1;
}
int main() {
  n = read(), q = read();
  init();
  while (q--) {
    int l = read(), r = read(), k = read();
    if (l > r) swap(l, r);
    update(1, 1, n, l, r, 2 - k);
    cout << n - tr[1].sum << "\n";
  }
}
