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:
/*
 * Author Ayub Subhaniya
 * Institute DA-IICT
 */
 
import java.io.*;
import java.math.*;
import java.util.*;
 
public class JuneLong{
	
	InputStream in;
	PrintWriter out;
	
	int MAX;
	int N;
	void solve() {
		int n=ni();
		int m=ni();
		int a[]=new int[n];
		for (int i=0;i<n;i++)
			a[i]=i+1;
		MAX=n;
		N=500;
		//tr(N);
		FenwickTree ft[]=new FenwickTree[N];
		for (int i=0;i<N;i++)
			ft[i]=new FenwickTree();
		
		for (int j=0;j<N;j++)
		{
			for (int i=N*j;i<Math.min(n, N*(j+1));i++)
			{
				ft[j].update(a[i],1);
			}
			//tr(N*j+" "+(Math.min(n, N*(j+1))-1));
		}
		
		long temp=0;
		for (int i=0;i<m;i++)
		{
			//tr(a);
			int a1=ni()-1;
			int a2=ni()-1;
			if (a1==a2)
			{
				out.println(temp);
				continue;
			}
			if (a1>a2)
			{
				int tmp=a1;
				a1=a2;
				a2=tmp;
			}
			//tr(a1+" "+a2);
			int bk1=a1/N;
			int bk2=a2/N;
			//tr(bk1+" "+bk2);
			if (bk1==bk2)
			{
				for (int j=a1+1;j<a2;j++)
					{
						if (a[j]>a[a1])
							temp++;
						else
							temp--;
						
						if (a[j]>a[a2])
							temp--;
						else
							temp++;
					}
				if (a[a1]>a[a2])
					temp--;
				else
					temp++;
			
				out.println(temp);
				
				int tmp=a[a1];
				a[a1]=a[a2];
				a[a2]=tmp;
				continue;
						
			}
			
			for (int j=bk1+1;j<bk2;j++)
			{
				if (a[a1]>a[a2])
				{
					temp-=(long)ft[j].query(a[a2]+1,a[a1]);
					temp-=(long)ft[j].query(a[a2],a[a1]-1);
				}
				else
				{
					temp+=(long)ft[j].query(a[a1]+1,a[a2]);
					temp+=(long)ft[j].query(a[a1],a[a2]-1);
				}
				
				//tr(temp);
			}
			
			for (int j=a1+1;j< N*(bk1+1);j++)
			{
				
				if (a[j]<a[a1])
					temp--;
				else
					temp++;
				
				if (a[j]<a[a2])
					temp++;
				else
					temp--;
				
			}
			//tr(temp);
			for (int j=N*bk2;j<a2;j++)
			{
			
				if (a[j]>a[a2])
					temp--;
				else
					temp++;
				
				if (a[j]>a[a1])
					temp++;
				else
					temp--;
			}
			//tr(temp);
			if (a[a1]>a[a2])
				temp--;
			else
				temp++;
			
			out.println(temp);
			
			ft[bk1].update(a[a1], -1);
			ft[bk1].update(a[a2], 1);
			ft[bk2].update(a[a2], -1);
			ft[bk2].update(a[a1], 1);
			int tmp=a[a1];
			a[a1]=a[a2];
			a[a2]=tmp;
		}
	}
	
	class FenwickTree {
		int size;
		int bit[];

		FenwickTree() {
			size = MAX;
			bit = new int[size + 1];
		}

		void update(int x, int val) {
			for (; x <= size; x += x & (-x))
				bit[x] += val;
		}

		int query(int x) {
			int sum = 0;
			for (; x > 0; x -= x & (-x))
				sum += bit[x];
			return sum;
		}
		
		int query(int l,int r)
		{
			return query(r)-query(l-1);
		}
	}
	
	class Merge {

		void sort(int inputArr[]) {
			int length = inputArr.length;
			doMergeSort(inputArr, 0, length - 1);
		}

		void doMergeSort(int[] arr, int lowerIndex, int higherIndex) {
			if (lowerIndex < higherIndex) {
				int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
				doMergeSort(arr, lowerIndex, middle);
				doMergeSort(arr, middle + 1, higherIndex);
				mergeParts(arr, lowerIndex, middle, higherIndex);
			}
		}

		void mergeParts(int[] array, int lowerIndex, int middle, int higherIndex) {
			int[] temp = new int[higherIndex - lowerIndex + 1];
			for (int i = lowerIndex; i <= higherIndex; i++) {
				temp[i - lowerIndex] = array[i];
			}
			int i = lowerIndex;
			int j = middle + 1;
			int k = lowerIndex;
			while (i <= middle && j <= higherIndex) {
				if (temp[i - lowerIndex] < temp[j - lowerIndex]) {
					array[k] = temp[i - lowerIndex];
					i++;
				} else {
					array[k] = temp[j - lowerIndex];
					j++;
				}
				k++;
			}
			while (i <= middle) {
				array[k] = temp[i - lowerIndex];
				k++;
				i++;
			}
			while (j <= higherIndex) {
				array[k] = temp[j - lowerIndex];
				k++;
				j++;
			}
		}

	}
	
	
	void run() throws Exception {
		String INPUT = "C:/Users/ayubs/Desktop/input.txt";
		in = oj ? System.in : new FileInputStream(INPUT);
		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 JuneLong().run();
	}
	
	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 = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean inSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}
	
	private int skip() {
		int b;
		while ((b = readByte()) != -1 && inSpaceChar(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 (!(inSpaceChar(b))) { // when nextLine, (inSpaceChar(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 && !(inSpaceChar(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));
	}
	
}