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;
const long long inf = 2000000007LL;
const double EPS = 1e-10;
const long long inf_ll = (long long)1e18;
const long long maxn = 300005LL;
const long long mod = 1000000007LL;
int n, q;
int l[maxn], r[maxn], opt[maxn];
vector<int> Hash;
struct Interval_Tree {
  struct node {
    int l, r, sum, set, size;
    node() {}
    node(int nl, int nr) : l(nl), r(nr), set(-1), size(0), sum(0) {}
  } T[maxn << 3];
  inline void push_up(int u) {
    T[u].sum = T[(u << 1)].sum + T[(u << 1 | 1)].sum;
  }
  inline void set_node(int u, int val) {
    T[u].set = val;
    T[u].sum = val * T[u].size;
  }
  inline void push_down(int u) {
    if (T[u].set >= 0) {
      set_node((u << 1), T[u].set);
      set_node((u << 1 | 1), T[u].set);
      T[u].set = -1;
    }
  }
  void _build(int u, int l, int r) {
    T[u] = node(l, r);
    if (l == r - 1) {
      T[u].size = Hash[r] - Hash[l];
      set_node(u, 1);
      return;
    }
    _build((u << 1), l, (l + r) >> 1);
    _build((u << 1 | 1), (l + r) >> 1, r);
    push_up(u);
    T[u].size = T[(u << 1)].size + T[(u << 1 | 1)].size;
  }
  inline void build(int size) { _build(1, 1, size); }
  void _modify_set(int u, int l, int r, int val) {
    int nl = T[u].l, nr = T[u].r;
    if (nl >= l && nr <= r) {
      set_node(u, val);
      return;
    }
    if (nl >= r || nr <= l) return;
    push_down(u);
    _modify_set((u << 1), l, r, val);
    _modify_set((u << 1 | 1), l, r, val);
    push_up(u);
  }
  inline void modify_set(int l, int r, int val) { _modify_set(1, l, r, val); }
  int _query_sum(int u, int l, int r) {
    int nl = T[u].l, nr = T[u].r;
    if (nl >= l && nr <= r) return T[u].sum;
    if (nl >= r || nr <= l) return 0;
    push_down(u);
    return _query_sum((u << 1), l, r) + _query_sum((u << 1 | 1), l, r);
  }
  inline int query_sum(int l, int r) { return _query_sum(1, l, r); }
  inline void print_node(int u) {
    printf("[%d] %d %d %d %d %d\n", u, T[u].l, T[u].r, T[u].size, T[u].sum,
           T[u].set);
  }
  void _print(int u) {
    int nl = T[u].l, nr = T[u].r;
    print_node(u);
    if (nl == nr - 1) return;
    _print((u << 1));
    _print((u << 1 | 1));
  }
  inline void print() { _print(1); }
} IT;
int main() {
  scanf("%d%d", &n, &q);
  Hash.push_back(1);
  Hash.push_back(0);
  Hash.push_back(n + 1);
  for (int(i) = (1); (i) <= (q); ++i) {
    scanf("%d%d%d", l + i, r + i, opt + i);
    Hash.push_back(l[i]);
    Hash.push_back(r[i] + 1);
  }
  sort(Hash.begin(), Hash.end());
  Hash.erase(unique(Hash.begin(), Hash.end()), Hash.end());
  int hash_size = (int)Hash.size();
  IT.build(hash_size - 1);
  for (int(i) = (1); (i) <= (q); ++i) {
    int nl = l[i], nr = r[i];
    nl = lower_bound(Hash.begin(), Hash.end(), nl) - Hash.begin();
    nr = lower_bound(Hash.begin(), Hash.end(), nr + 1) - Hash.begin();
    if (opt[i] ^ 2)
      IT.modify_set(nl, nr, 0);
    else
      IT.modify_set(nl, nr, 1);
    printf("%d\n", IT.query_sum(1, hash_size - 1));
  }
  return 0;
}