Problem: This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend physical education lessons. The end of the term is very soon, but, unfortunately, Alex still hasn't attended a single lesson!

Since Alex doesn't want to get expelled, he wants to know the number of working days left until the end of the term, so he can attend physical education lessons during these days. But in BSU calculating the number of working days is a complicated matter:

There are n days left before the end of the term (numbered from 1 to n), and initially all of them are working days. Then the university staff sequentially publishes q orders, one after another. Each order is characterised by three numbers l, r and k:

  * If k = 1, then all days from l to r (inclusive) become non-working days. If some of these days are made working days by some previous order, then these days still become non-working days; 
  * If k = 2, then all days from l to r (inclusive) become working days. If some of these days are made non-working days by some previous order, then these days still become working days. 



Help Alex to determine the number of working days left after each order!

Input

The first line contains one integer n, and the second line — one integer q (1 ≤ n ≤ 109, 1 ≤ q ≤ 3·105) — the number of days left before the end of the term, and the number of orders, respectively.

Then q lines follow, i-th line containing three integers li, ri and ki representing i-th order (1 ≤ li ≤ ri ≤ n, 1 ≤ ki ≤ 2).

Output

Print q integers. i-th of them must be equal to the number of working days left until the end of the term after the first i orders are published.

Example

Input

4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2


Output

2
0
2
3
1
4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
const long long int INF = 1e18;
int val[600005];
vector<int> compress(vector<int> &temp, int n) {
  vector<pair<int, int> > tp(n);
  int i, j, k;
  for (i = 0; i < n; i++) tp[i].first = temp[i], tp[i].second = i;
  sort(tp.begin(), tp.end());
  vector<int> v(n);
  i = 0, k = 1, j = 0;
  while (i < n) {
    val[k] = tp[i].first;
    while (j < n && tp[i].first == tp[j].first) v[tp[j].second] = k, j++;
    i = j, k++;
  }
  return v;
}
int work[4 * 600005], flag[4 * 600005];
void pull(int p) {
  if (flag[2 * p] == flag[2 * p + 1])
    flag[p] = flag[2 * p];
  else
    flag[p] = 2;
  work[p] = work[2 * p] + work[2 * p + 1];
}
void build(int l, int h, int p) {
  if (l == h) {
    work[p] = val[l] - val[l - 1], flag[p] = 1;
    return;
  }
  int m = ((l + h) >> 1);
  build(l, m, 2 * p);
  build(m + 1, h, 2 * p + 1);
  pull(p);
  return;
}
void update(int a, int b, int l, int h, int p, int f) {
  if (b < l || a > h) return;
  if (flag[p] == f) return;
  if (a <= l && b >= h) {
    flag[p] = f;
    if (f)
      work[p] = val[h] - val[l - 1];
    else
      work[p] = 0;
    return;
  }
  int m = ((l + h) >> 1);
  if (flag[p] < 2) {
    flag[2 * p] = flag[p];
    flag[2 * p + 1] = flag[p];
    if (flag[p])
      work[2 * p] = val[m] - val[l - 1], work[2 * p + 1] = val[h] - val[m];
    else
      work[2 * p] = 0, work[2 * p + 1] = 0;
  }
  update(a, b, l, m, 2 * p, f);
  update(a, b, m + 1, h, 2 * p + 1, f);
  pull(p);
  return;
}
int main() {
  int n, m, i, a, b, k, ans;
  scanf("%d", &n);
  scanf("%d", &m);
  vector<int> v(2 * m), on(m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    scanf("%d", &on[i]);
    on[i]--;
    b++;
    v[i] = a, v[i + m] = b;
  }
  v.emplace_back(n + 1);
  k = v.size();
  v = compress(v, k);
  n = v[k - 1];
  val[0] = 1;
  build(1, n, 1);
  for (i = 0; i < m; i++) {
    update(v[i] + 1, v[i + m], 1, n, 1, on[i]);
    printf("%d\n", work[1]);
  }
}