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

Solution:
#include <bits/stdc++.h>
using namespace std;
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT &...rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cout << b << "=" << a << " ";
    call(++it, ed, rest...);
  }
};
int N, BCNT, BSZ, Q;
int A[300010 + 100];
int BLOCK[888][888];
int n;
int bucket[1 << 8], temp[300010 + 10];
void radix_sort(int *ar, int n) {
  int i, j, x;
  const int bitmask = (1 << 8) - 1;
  for (i = 0; i < 24; i += 8) {
    memset(bucket, 0, sizeof(bucket));
    for (j = 0; j < n; j++) bucket[(ar[j] >> i) & bitmask]++;
    for (j = 1; j <= bitmask; j++) {
      bucket[j] += bucket[j - 1];
    }
    for (j = n - 1; j >= 0; j--) temp[--bucket[(ar[j] >> i) & bitmask]] = ar[j];
    for (j = 0; j < n; j++) ar[j] = temp[j];
  }
}
void build(int idx) {
  int st = idx * BSZ;
  int ed = (idx + 1) * BSZ;
  for (int i = st, j = 0; i < ed; i++, j++) {
    BLOCK[idx][j] = A[i];
  }
  radix_sort(BLOCK[idx], BSZ);
}
int get(int idx, int K) {
  int up = upper_bound(BLOCK[idx], BLOCK[idx] + BSZ, K) - BLOCK[idx];
  return (BSZ - up);
}
int main() {
  scanf("%d%d", &N, &Q);
  for (int i = 0; i < N; i++) {
    A[i] = i + 1;
  }
  BSZ = 800;
  BCNT = (N / BSZ) + (N % BSZ != 0);
  for (int i = 0; i < BCNT; i++) {
    build(i);
  }
  long long ans = 0;
  for (int j = 0; j < Q; j++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x != y) {
      if (x > y) swap(x, y);
      int i = x;
      int k1 = A[x - 1], k2 = A[y - 1];
      long long a1 = 0, a2 = 0;
      for (; i % BSZ != 0 && i <= y - 2; i++) {
        a1 += (A[i] > k1);
        a2 += (A[i] > k2);
      }
      for (; i + BSZ <= y - 2; i += BSZ) {
        a1 += get(i / BSZ, k1);
        a2 += get(i / BSZ, k2);
      }
      for (; i <= y - 2; i++) {
        a1 += (A[i] > k1);
        a2 += (A[i] > k2);
      }
      long long rg = (y - x - 1);
      ans += +a1 - (rg - a1);
      ans += -a2 + (rg - a2);
      if (A[x - 1] < A[y - 1])
        ans += 1;
      else
        ans -= 1;
      swap(A[x - 1], A[y - 1]);
      build((x - 1) / BSZ);
      build((y - 1) / BSZ);
    }
    printf("%lld\n", ans);
  }
}