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 JAVA):

Solution:
//package kanak;
import java.util.*;
import java.lang.*;
import java.io.*;


public  class Solution implements Runnable{
    static TreeSet<seg> tr;
    public static void main(String[] args) {
        new Thread(null,new Solution(),"cf",1<<27).start();
    }
    public  void run(){
    InputReader fi=new InputReader(System.in);
    int n,q,i,j;
    n=fi.nextInt();
    q=fi.nextInt();
   tr =new TreeSet<seg>();
    PrintWriter out=new PrintWriter(System.out);
    int ans=n;
    tr.add(new seg(1,n));
    while (q-- > 0){
        int l=fi.nextInt();
        int r=fi.nextInt();
        int k=fi.nextInt();

        //if (k==1)
          ans=update(l,r,ans);

        if (k==2)
            {
            ans=ans+(r-l+1);
            tr.add(new seg(l,r));
        }



        out.println(ans);


    }
    out.close();


    }

    static int update(int l,int r,int ans){
        seg below,check;
        check=new seg(r,Integer.MAX_VALUE);
        while ((below=tr.floor(check))!=null && !(below.r < l) ) {
         //   System.out.println(" below l " + below.l+ " below r = " +below.r + " ql " +l + " qr " +r );
            ans=ans-(below.r-below.l+1);
            tr.remove(below);
            if (below.r > r ){
                tr.add(new seg(r+1,below.r));
                ans=ans+below.r-r;
            }
            if (below.l  < l){
                tr.add(new seg( below.l,l-1));
                ans=ans+l-below.l;
            }
        }
        return  ans;
    }



}
class  seg implements  Comparable<seg>{
    int l;
    int r;

    seg(int l,int r){
        this.l=l;
        this.r=r;
    }
    public  int compareTo(seg x){
       return Integer.compare(this.l,x.l);
    }
}


class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = nextInt();
        return a;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}