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 fastIO() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <typename T, typename U>
inline void mnze(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void mxze(T &x, U y) {
  if (x < y) x = y;
}
void _scan(int &x) { scanf("%d", &x); }
void _scan(long long &x) { scanf("%lld", &x); }
void _scan(double &x) { scanf("%lf", &x); }
void _scan(char &x) { scanf(" %c", &x); }
void _scan(char *x) { scanf("%s", x); }
void scan() {}
template <typename T, typename... U>
void scan(T &head, U &...tail) {
  _scan(head);
  scan(tail...);
}
template <typename T>
void _dbg(const char *sdbg, T h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename T, typename... U>
void _dbg(const char *sdbg, T h, U... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
struct order {
  int l, r, k;
  bool operator<(const order &o) const { return l < o.l; }
};
int n, q;
set<order> s;
int total;
bool change_nxt(int l, int r, int k) {
  auto it = s.lower_bound({l, -1, -1});
  if (it == s.end()) return false;
  if (it->l > r) return false;
  int sz = (it->r) - (it->l) + 1, ik = it->k;
  if (it->r <= r) {
    s.erase(it);
    if (ik == 2) total -= sz;
    return true;
  } else {
    int rr = it->r, kk = it->k;
    s.erase(it);
    if (ik == 2) total -= sz;
    s.insert({r + 1, rr, kk});
    if (ik == 2) total += rr - (r + 1) + 1;
    return false;
  }
}
void change_prv(int l, int r, int k) {
  auto it = s.lower_bound({l, -1, -1});
  if (it == s.begin()) return;
  it--;
  if (it->r < l) return;
  int il = it->l, ir = it->r, ik = it->k, sz = (it->r) - (it->l) + 1;
  s.erase(it);
  if (ik == 2) total -= sz;
  s.insert({il, l - 1, ik});
  if (ik == 2) total += (l - 1) - (il) + 1;
  if (ir > r) {
    s.insert({r + 1, ir, ik});
    if (ik == 2) total += ir - (r + 1) + 1;
  }
}
int main() {
  scan(n, q);
  s.insert({1, n, 2});
  total = n;
  while (q--) {
    int l, r, k;
    scan(l, r, k);
    while (change_nxt(l, r, k))
      ;
    change_prv(l, r, k);
    int sz = r - l + 1;
    s.insert({l, r, k});
    if (k == 2) total += sz;
    printf("%d\n", total);
  }
}