Problem: 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.

Solution (in JAVA):

Solution:
import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class CODEFORCES {
	private InputStream is;
	private PrintWriter out;

	class ST {
		int n;
		int arr[];

		ST(int a) {
			n = a;
			arr = new int[n + 1];
		}

		void u(int ind, int val) {
			ind++;
			while (ind <= n) {
				arr[ind] += val;
				ind += (ind & (-ind));
			}
		}

		int an(int l, int r) {
			return ans(r) - ans(l - 1);
		}

		int ans(int ind) {
			int sum = 0;
			ind++;
			while (ind > 0) {
				sum += arr[ind];
				ind -= (ind & (-ind));
			}
			return sum;
		}
	}

	void solve() {
		int n = ni(), q = ni();
		int sq = (int) Math.sqrt(n);
		ST s[] = new ST[sq + 2];
		for (int i = 0; i < s.length; i++)
			s[i] = new ST(n);
		int block[] = new int[n], a[] = new int[n], index[] = new int[n];
		for (int i = 0; i < n; i++) {
			block[i] = i / sq;
			a[i] = i;
			index[i] = i;
			s[block[i]].u(i, 1);
		}
		long ans = 0;
		while (q-- > 0) {
			int l = ni() - 1, r = ni() - 1;
			if (l > r) {
				int di = l;
				l = r;
				r = di;
			}
			if (l == r) {
				out.println(ans);
				continue;
			}
			int ml = 0;
			for (int i = block[a[l]] + 1; i < block[a[r]]; i++)
				ml += s[i].an(l + 1, r - 1);
			ans += ml * 2;
			ml = 0;
			for (int i = block[a[r]] + 1; i < block[a[l]]; i++)
				ml += s[i].an(l + 1, r - 1);
			ans -= ml * 2;
			ml = 0;
			if (block[a[l]] == block[a[r]]) {
				int jk = 2;
				if (a[r] < a[l])
					jk = -2;
				for (int i = Math.min(a[l], a[r]) + 1; i < Math.max(a[l], a[r]); i++) {
					if (index[i] > l && index[i] < r)
						ans += jk;
				}
			} else {
				if (a[l] < a[r]) {
					int jk = 2;
					for (int i = a[l] + 1; i < (block[a[l]] + 1) * sq; i++) {
						if (index[i] > l && index[i] < r)
							ans += jk;
					}
					for (int i = block[a[r]] * sq; i < a[r]; i++) {
						if (index[i] > l && index[i] < r)
							ans += jk;
					}
				} else {
					int jk = -2;
					for (int i = a[r] + 1; i < (block[a[r]] + 1) * sq; i++) {
						if (index[i] > l && index[i] < r)
							ans += jk;
					}
					for (int i = block[a[l]] * sq; i < a[l]; i++) {
						if (index[i] > l && index[i] < r)
							ans += jk;
					}
				}
			}
			if (a[l] < a[r])
				ans++;
			else
				ans--;
			s[block[a[l]]].u(l, -1);
			s[block[a[r]]].u(r, -1);
			s[block[a[l]]].u(r, +1);
			s[block[a[r]]].u(l, +1);
			index[a[l]] = r;
			index[a[r]] = l;
			ml = a[l];
			a[l] = a[r];
			a[r] = ml;
			out.println(ans);
		}
	}

	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new CODEFORCES().soln();
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}