Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.

One day Anton got a new permutation and started to play with it. He does the following operation q times: he takes two elements of the permutation and swaps these elements. After each operation he asks his friend Vanya, how many inversions there are in the new permutation. The number of inversions in a permutation is the number of distinct pairs (i, j) such that 1 ≤ i < j ≤ n and ai > aj.

Vanya is tired of answering Anton's silly questions. So he asked you to write a program that would answer these questions instead of him.

Initially Anton's permutation was {1, 2, ..., n}, that is ai = i for all i such that 1 ≤ i ≤ n.

Input

The first line of the input contains two integers n and q (1 ≤ n ≤ 200 000, 1 ≤ q ≤ 50 000) — the length of the permutation and the number of operations that Anton does.

Each of the following q lines of the input contains two integers li and ri (1 ≤ li, ri ≤ n) — the indices of elements that Anton swaps during the i-th operation. Note that indices of elements that Anton swaps during the i-th operation can coincide. Elements in the permutation are numbered starting with one.

Output

Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.

Examples

Input

5 4
4 5
2 4
2 5
2 2


Output

1
4
3
3


Input

2 1
2 1


Output

1


Input

6 7
1 4
3 5
2 3
3 3
3 6
2 1
5 1


Output

5
6
7
7
10
11
8

Note

Consider the first sample.

After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).

After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).

After the third Anton's operation the permutation will be {1, 4, 3, 2, 5}. There are three inversions: (2, 3), (2, 4) and (3, 4).

After the fourth Anton's operation the permutation doesn't change, so there are still three inversions.
import java.io.*;
import java.util.*;

public class InversionNSqrtNNoVectors {
	private static final int BLOCK_SZ_Q = 256;
	private static final int BLOCK_SZ_N = 512;
	
	public static class ToProcess {
		public int x, y1, y2, sgn, id;
		
		public void set(int pX, int pY1, int pY2, int pSgn, int pId) {
			x = pX;
			y1 = pY1;
			y2 = pY2;
			sgn = pSgn;
			id = pId;
		}
		
		public ToProcess() {
		}
	}
	
	public static class ToProcessCompareAsc implements Comparator<ToProcess> {
		@Override
		public int compare(ToProcess o1, ToProcess o2) {
			return o1.x - o2.x;
		}
	}
	
	public static class ToProcessCompareDesc implements Comparator<ToProcess> {
		@Override
		public int compare(ToProcess o1, ToProcess o2) {
			return o2.x - o1.x;
		}
	}
	
	static int n, q;
	static int[] p;
	static ToProcess[] queryL, queryR;
	static int queryLCnt, queryRCnt;
	static SQRTDecomposition sum;
	static ToProcessCompareAsc ascCmp = new ToProcessCompareAsc();
	static ToProcessCompareDesc descCmp = new ToProcessCompareDesc();
	
	public static final void add(int q, int sgn, int id) {
		if (q-1 >= 0) {
			queryL[queryLCnt++].set(q-1, p[q]+1, n-1, sgn, id);
		}
		if (q+1 < n) {
			queryR[queryRCnt++].set(q+1, 0, p[q]-1, sgn, id);
		}
	}
	
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		n = Integer.parseInt(tokenizer.nextToken());
		q = Integer.parseInt(tokenizer.nextToken());
		int[] qL = new int[q], qR = new int[q];
		long[] ans = new long[q], preAns = new long[q];
		p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = i;
		}
		for (int i = 0; i < q; i++) {
			tokenizer = new StringTokenizer(reader.readLine());
			qL[i] = Integer.parseInt(tokenizer.nextToken()) - 1;
			qR[i] = Integer.parseInt(tokenizer.nextToken()) - 1;
		}
		long cnt = 0;
		boolean[] good = new boolean[n];
		int[] goods = new int[n];
		int goodsSize = 0;
		queryL = new ToProcess[4 * BLOCK_SZ_Q]; queryR = new ToProcess[4 * BLOCK_SZ_Q];
		for (int j = 0; j < 4 * BLOCK_SZ_Q; j++) {
			queryL[j] = new ToProcess();
			queryR[j] = new ToProcess();
		}
		SQRTDecomposition sum = new SQRTDecomposition(n, BLOCK_SZ_N);
		for (int i = 0; i < q; i += BLOCK_SZ_Q) {
			int iEnd = Math.min(q, i + BLOCK_SZ_Q);
			Arrays.fill(good, false);
			for (int j = i; j < iEnd; j++) {
				good[qL[j]] = true;
				good[qR[j]] = true;
			}
			goodsSize = 0;
			for (int j = 0; j < n; j++) {
				if (good[j]) {
					goods[goodsSize++] = j;
				}
			}
			long goodCnt = 0;
			queryLCnt = 0;
			queryRCnt = 0;
			for (int j = i; j < iEnd; j++) {
				int a = qL[j], b = qR[j];
				if (a == b) {
					ans[j] += goodCnt;
					continue;
				}
				for (int k = 0; k < goodsSize; k++) {
					int q = goods[k];
					if (q == a || q == b) {
						continue;
					}
					if ((p[q] < p[a] && q > a) ||
						(p[q] > p[a] && q < a)) {
						goodCnt--;
					}
					if ((p[q] < p[b] && q > b) ||
						(p[q] > p[b] && q < b)) {
						goodCnt--;
					}
					if ((p[q] < p[b] && q > a) ||
						(p[q] > p[b] && q < a)) {
						goodCnt++;
					}
					if ((p[q] < p[a] && q > b) ||
						(p[q] > p[a] && q < b)) {
						goodCnt++;
					}
				}
				if ((a < b && p[a] > p[b]) ||
					(a > b && p[a] < p[b])) {
					goodCnt--;
				} else {
					goodCnt++;
				}
				ans[j] += goodCnt;
				add(a, -1, j);
				add(b, -1, j);
				int tmp = p[a];
				p[a] = p[b];
				p[b] = tmp;
				add(a, +1, j);
				add(b, +1, j);
			}
			sum.clear();
			Arrays.sort(queryL, 0, queryLCnt, ascCmp);
			int curL = 0;
			for (int j = 0; j < n; j++) {
				if (!good[j]) {
					sum.add(p[j], 1);
				}
				for (; curL < queryLCnt; curL++) {
					ToProcess cur = queryL[curL];
					if (cur.x != j) {
						break;
					}
					int res = sum.sum(cur.y1, cur.y2);
					res *= cur.sgn;
					preAns[cur.id] += res;
				}
			}
			sum.clear();
			Arrays.sort(queryR, 0, queryRCnt, descCmp);
			int curR = 0;
			for (int j = n-1; j >= 0; j--) {
				if (!good[j]) {
					sum.add(p[j], 1);
				}
				for (; curR < queryRCnt; curR++) {
					ToProcess cur = queryR[curR];
					if (cur.x != j) {
						break;
					}
					int res = sum.sum(cur.y1, cur.y2);
					res *= cur.sgn;
					preAns[cur.id] += res;
				}
			}
			for (int j = i; j < iEnd; j++) {
				if (j != i) {
					preAns[j] += preAns[j-1];	
				}
				ans[j] += cnt + preAns[j];
			}
			cnt = ans[iEnd - 1];
		}
		for (int i = 0; i < q; i++) {
			writer.write(Long.toString(ans[i]));
			writer.newLine();
		}
		reader.close();
		writer.close();
	}
}

class SQRTDecomposition {
	private int n;
	private int sz;
	private int[] val;
	private int[] blocks;
	
	public final void add(int v, int delta) {
		val[v] += delta;
		blocks[v / sz] += delta;
	}
		
	public final int sum(int l, int r) {	
		if (l < 0) {
			l = 0;
		}
		if (r >= n) {
			r = n;
		}
		r++;
		int res = 0;
		int lBlock = (l + sz - 1) / sz, rBlock = r / sz;
		for (int i = lBlock; i < rBlock; i++) {
			res += blocks[i];
		}
		int lBlockR = lBlock * sz, rBlockR = rBlock * sz;
		if (lBlockR >= rBlockR) {
			for (int i = l; i < r; i++) {
				res += val[i];
			}
		} else {
			for (int i = l; i < lBlockR; i++) {
				res += val[i];
			}
			for (int i = rBlockR; i < r; i++) {
				res += val[i];
			}
		}
		return res;
	}
	
	public void clear() {
		Arrays.fill(val, 0);
		Arrays.fill(blocks, 0);
	}
		
	SQRTDecomposition(int pN, int pSz) {
		n = pN;
		sz = pSz;
		val = new int[n];
		blocks = new int[(n + sz - 1) / sz];
	}
}