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;
template <class T>
T sqr(T x) {
  return x * x;
}
long double pi = 3.1415926535897932384626433832795;
long long mod = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long _gcd(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long _x1, _y1;
  long long d = _gcd(b % a, a, _x1, _y1);
  x = _y1 - (b / a) * _x1;
  y = _x1;
  return d;
}
long double binpow(long double a, long long n) {
  long double res = 1;
  while (n) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
const int N = 2e5 + 10, bsize = 300;
int n, q, a[N];
vector<int> b[N / bsize + 10];
long long get(int l, int r) {
  long long ans = 0;
  int vl = a[l], vr = a[r];
  if (vl > vr) swap(vl, vr);
  l++;
  while (l < r && (l % bsize)) {
    ans += ((vl <= a[l]) && (a[l] < vr));
    l++;
  }
  while (l + bsize <= r) {
    int i = l / bsize;
    ans += lower_bound(b[i].begin(), b[i].end(), vr) -
           lower_bound(b[i].begin(), b[i].end(), vl);
    l += bsize;
  }
  while (l < r) {
    ans += ((vl <= a[l]) && (a[l] < vr));
    l++;
  }
  return ans;
}
void stand(int vl, int p) {
  int bl = p / bsize;
  p = find(b[bl].begin(), b[bl].end(), a[p]) - b[bl].begin();
  b[bl][p] = vl;
  while (p < b[bl].size() - 1 && b[bl][p] > b[bl][p + 1])
    swap(b[bl][p], b[bl][p + 1]), p++;
  while (p > 0 && b[bl][p] < b[bl][p - 1]) swap(b[bl][p], b[bl][p - 1]), p--;
}
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    b[i / bsize].push_back(i);
    a[i] = i;
  }
  long long inv = 0;
  for (int qq = 0; qq < q; qq++) {
    int l, r;
    cin >> l >> r;
    if (l != r) {
      if (l > r) swap(l, r);
      long long delta = get(l, r);
      if (a[l] < a[r])
        inv += 2 * delta + 1;
      else
        inv -= 2 * delta + 1;
      stand(a[l], r);
      stand(a[r], l);
      swap(a[l], a[r]);
    }
    cout << inv << endl;
  }
  return 0;
}