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:
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 1000000007;
	static long inf = (long) 1e14;
	static int n, m, vx, vy, vz;
	static ArrayList<Integer>[] ad;
	static int[][] memo;
	static boolean f;
	static boolean vis[];
	static int[] sub;
	static int[] a;
	static long ans;
	static HashSet<Integer> hm;
	static int[] point;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		TreeSet<int[]> ts = new TreeSet<>((x, y) -> x[1] - y[1]);
		int ans = n;
		int q = sc.nextInt();
		while (q-- > 0) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			if (sc.nextInt() == 1) {
				int[] seg = new int[] { l, r };
				ans -= r - l + 1;
				boolean f=true;
				while (true) {
					int[] ll = ts.ceiling(new int[] { 0, l });
					if (ll == null)
						break;
					ts.remove(ll);
					if (ll[0] > seg[1]) {
						ts.add(ll);
						break;
					}
					if (ll[1] <= seg[1] && ll[0] >= seg[0]) {
						ans += ll[1] - ll[0] + 1;
						continue;
					}
					if (ll[0] <= seg[0] && ll[1] >= seg[1]) {
						ans += seg[1] - seg[0] + 1;
f=false;
						ts.add(ll);
						break;
					}
					if (ll[1] <= seg[1] && ll[0] < seg[0]) {
						ans += ll[1] - l + 1;
						seg[0] = ll[0];
						continue;
					}
					if (ll[0] >= seg[0] && seg[1] < ll[1]) {
						ans += seg[1] - ll[0] + 1;
						seg[1] = ll[1];
						continue;
					}
				
				}
		if(f)
				ts.add(new int[] { seg[0], seg[1] });
			} else {
				int[] seg = new int[] { l, r };
				while (true) {
					int[] ll = ts.ceiling(new int[] { 0, l });
					if (ll == null)
						break;
					ts.remove(ll);
					if (ll[0] > seg[1]) {
						ts.add(ll);
						break;
					}
					if (ll[1] <= seg[1] && ll[0] >= seg[0]) {
						ans += ll[1] - ll[0] + 1;
						continue;
					}
					if (ll[0] <= seg[0] && ll[1] >= seg[1]) {
						ans += seg[1] - seg[0] + 1;
						if (seg[0] - 1 >= ll[0])
							ts.add(new int[] { ll[0], seg[0] - 1 });
						if (seg[1] + 1 <= ll[1])
							ts.add(new int[] { seg[1] + 1, ll[1] });
						break;
					}
					if (ll[1] <= seg[1] && ll[0] < seg[0]) {
						ans += ll[1] - seg[0] + 1;
						if (seg[0] - 1 >= ll[0])
							ts.add(new int[] { ll[0], seg[0] - 1 });
						continue;
					}
					if (ll[0] >= seg[0] && seg[1] < ll[1]) {
						ans += seg[1] - ll[0] + 1;
						if (seg[1] + 1 <= ll[1])
							ts.add(new int[] { seg[1] + 1, ll[1] });
						continue;
					}
				}
			}
		//	for(int []j:ts)
			//	out.println(Arrays.toString(j));
			out.println(ans);
		}
		out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}