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;
const int Maxn = 200005;
const int Maxm = 1048576;
int n, q;
int val[Maxn], ind[Maxn];
int L[Maxn], R[Maxn];
vector<int> inind[Maxn];
vector<int> st[Maxm], BITL[Maxm], BITR[Maxm];
int qa[Maxn], qb[Maxn];
long long res;
void insertLeft(vector<int> &BIT, int ind, int val) {
  for (int i = ind; i < BIT.size(); i += i & -i) BIT[i] += val;
}
void insertRight(vector<int> &BIT, int ind, int val) {
  for (int i = ind; i > 0; i -= i & -i) BIT[i] += val;
}
int getLeft(vector<int> &BIT, int ind) {
  int res = 0;
  for (int i = ind; i > 0; i -= i & -i) res += BIT[i];
  return res;
}
int getRight(vector<int> &BIT, int ind) {
  int res = 0;
  for (int i = ind; i < BIT.size(); i += i & -i) res += BIT[i];
  return res;
}
void Create(int v, int l, int r) {
  if (l == r) {
    sort(inind[l].begin(), inind[l].end());
    inind[l].erase(unique(inind[l].begin(), inind[l].end()), inind[l].end());
    st[v] = inind[l];
  } else {
    int m = l + r >> 1;
    int lc = 2 * v, rc = 2 * v + 1;
    Create(lc, l, m);
    Create(rc, m + 1, r);
    int i = 0, j = 0;
    while (i < st[lc].size() || j < st[rc].size())
      if (i < st[lc].size() && (j == st[rc].size() || st[lc][i] < st[rc][j]))
        st[v].push_back(st[lc][i++]);
      else if (j < st[rc].size() &&
               (i == st[lc].size() || st[rc][j] < st[lc][i]))
        st[v].push_back(st[rc][j++]);
      else {
        st[v].push_back(st[lc][i]);
        i++;
        j++;
      }
  }
  BITL[v].resize(st[v].size() + 1, 0);
  BITR[v].resize(st[v].size() + 1, 0);
}
int Get(int v, int l, int r, int a, int b, int val, bool les) {
  if (a > b) return 0;
  if (l == a && r == b) {
    int ind = lower_bound(st[v].begin(), st[v].end(), val) - st[v].begin() + 1;
    return les ? getLeft(BITL[v], ind - 1) : getRight(BITR[v], ind);
  } else {
    int res = 0;
    int m = l + r >> 1;
    if (a <= m) res += Get(2 * v, l, m, a, min(m, b), val, les);
    if (m + 1 <= b) res += Get(2 * v + 1, m + 1, r, max(m + 1, a), b, val, les);
    return res;
  }
}
void Update(int v, int l, int r, int x, int val, int add) {
  int ind = lower_bound(st[v].begin(), st[v].end(), val) - st[v].begin() + 1;
  insertLeft(BITL[v], ind, add);
  insertRight(BITR[v], ind, add);
  if (l < r) {
    int m = l + r >> 1;
    if (x <= m)
      Update(2 * v, l, m, x, val, add);
    else
      Update(2 * v + 1, m + 1, r, x, val, add);
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; i++) {
    ind[i] = val[i] = i;
    inind[i].push_back(i);
  }
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &qa[i], &qb[i]);
    if (qa[i] > qb[i]) swap(qa[i], qb[i]);
    if (qa[i] != qb[i]) {
      int a = val[qa[i]], b = val[qb[i]];
      val[qb[i]] = a;
      val[qa[i]] = b;
      ind[a] = qb[i];
      ind[b] = qa[i];
      inind[qb[i]].push_back(a);
      inind[qa[i]].push_back(b);
    }
  }
  Create(1, 1, n);
  for (int i = 1; i <= n; i++) {
    ind[i] = val[i] = i;
    Update(1, 1, n, i, i, 1);
  }
  for (int i = 0; i < q; i++) {
    if (qa[i] != qb[i]) {
      int a = val[qa[i]], b = val[qb[i]];
      Update(1, 1, n, qa[i], a, -1);
      res -= Get(1, 1, n, 1, qa[i], a, false) + Get(1, 1, n, qa[i], n, a, true);
      Update(1, 1, n, qb[i], b, -1);
      res -= Get(1, 1, n, 1, qb[i], b, false) + Get(1, 1, n, qb[i], n, b, true);
      val[qb[i]] = a;
      ind[a] = qb[i];
      res += Get(1, 1, n, 1, qb[i], a, false) + Get(1, 1, n, qb[i], n, a, true);
      Update(1, 1, n, qb[i], a, 1);
      val[qa[i]] = b;
      ind[b] = qa[i];
      res += Get(1, 1, n, 1, qa[i] - 1, b, false) +
             Get(1, 1, n, qa[i] + 1, n, b, true);
      Update(1, 1, n, qa[i], b, 1);
    }
    printf("%I64d\n", res);
  }
  return 0;
}