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;
class SQRTDecomposition {
 private:
  int n, sz;
  vector<int> val;
  vector<int> blocks;

 public:
  inline void add(int v, int delta) {
    val[v] += delta;
    blocks[v / sz] += delta;
  }
  inline 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;
  }
  inline void clear() {
    val.assign(val.size(), 0);
    blocks.assign(blocks.size(), 0);
  }
  SQRTDecomposition(int n, int sz)
      : n(n), sz(sz), val(n, 0), blocks((n + sz - 1) / sz, 0) {}
};
struct ToProcess {
  int x, y1, y2, sgn, id;
};
const int BLOCK_SZ_Q = 256;
const int BLOCK_SZ_N = 512;
const int MAX_N = 200000;
int n, q;
vector<ToProcess> sortedL[MAX_N], sortedR[MAX_N];
SQRTDecomposition sum(MAX_N, BLOCK_SZ_N);
int64_t ans[MAX_N], preAns[MAX_N];
pair<int, int> queries[MAX_N];
vector<int> goods;
int p[MAX_N];
bool good[MAX_N];
inline void add(int q, int sgn, int id) {
  if (q - 1 >= 0) {
    sortedL[q - 1].push_back({q - 1, p[q] + 1, n - 1, sgn, id});
  }
  if (q + 1 < n) {
    sortedR[q + 1].push_back({q + 1, 0, p[q] - 1, sgn, id});
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }
  for (int i = 0; i < q; i++) {
    cin >> queries[i].first >> queries[i].second;
    queries[i].first--;
    queries[i].second--;
  }
  int64_t cnt = 0;
  for (int i = 0; i < q; i += BLOCK_SZ_Q) {
    int iEnd = min(q, i + BLOCK_SZ_Q);
    for (int j = 0; j < n; j++) {
      good[j] = false;
    }
    for (int j = i; j < iEnd; j++) {
      good[queries[j].first] = true;
      good[queries[j].second] = true;
    }
    goods.clear();
    for (int j = 0; j < n; j++) {
      if (good[j]) {
        goods.push_back(j);
      }
    }
    int64_t goodCnt = 0;
    for (int j = 0; j < n; j++) {
      sortedL[j].clear();
      sortedR[j].clear();
    }
    for (int j = i; j < iEnd; j++) {
      int a = queries[j].first, b = queries[j].second;
      if (a == b) {
        ans[j] += goodCnt;
        continue;
      }
      for (int k = 0; k < (int)goods.size(); 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);
      swap(p[a], p[b]);
      add(a, +1, j);
      add(b, +1, j);
    }
    sum.clear();
    for (int j = 0; j < n; j++) {
      if (!good[j]) {
        sum.add(p[j], 1);
      }
      for (int k = 0; k < (int)sortedL[j].size(); k++) {
        ToProcess &cur = sortedL[j][k];
        int64_t res = sum.sum(cur.y1, cur.y2);
        res *= cur.sgn;
        preAns[cur.id] += res;
      }
    }
    sum.clear();
    for (int j = n - 1; j >= 0; j--) {
      if (!good[j]) {
        sum.add(p[j], 1);
      }
      for (int k = 0; k < (int)sortedR[j].size(); k++) {
        ToProcess &cur = sortedR[j][k];
        int64_t 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++) {
    cout << ans[i] << "\n";
  }
  return 0;
}