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 N = 200000 + 5;
typedef struct node {
  int val, prior, size;
  struct node *l, *r;
} node;
typedef node *pnode;
int sz(pnode t) { return t ? t->size : 0; }
void upd_sz(pnode t) {
  if (t) t->size = sz(t->l) + 1 + sz(t->r);
}
void split(pnode t, pnode &l, pnode &r, int key) {
  if (!t)
    l = r = NULL;
  else if (t->val <= key)
    split(t->r, t->r, r, key), l = t;
  else
    split(t->l, l, t->l, key), r = t;
  upd_sz(t);
}
void merge(pnode &t, pnode l, pnode r) {
  if (!l || !r)
    t = l ? l : r;
  else if (l->prior > r->prior)
    merge(l->r, l->r, r), t = l;
  else
    merge(r->l, l, r->l), t = r;
  upd_sz(t);
}
void insert(pnode &t, pnode it) {
  if (!t)
    t = it;
  else if (it->prior > t->prior)
    split(t, it->l, it->r, it->val), t = it;
  else
    insert(t->val <= it->val ? t->r : t->l, it);
  upd_sz(t);
}
void erase(pnode &t, int key) {
  if (!t)
    return;
  else if (t->val == key) {
    pnode temp = t;
    merge(t, t->l, t->r);
    free(temp);
  } else
    erase(t->val < key ? t->r : t->l, key);
  upd_sz(t);
}
pnode init(int val) {
  pnode ret = new node();
  ret->val = val;
  ret->size = 1;
  ret->prior = rand();
  ret->l = ret->r = NULL;
  return ret;
}
bool search(pnode n, int k) {
  if (!n) return false;
  if (n->val == k) return 1;
  if (k > n->val) return search(n->r, k);
  return search(n->l, k);
}
int findKth(pnode n, int k) {
  if (!n) return 10000000000ll;
  if (sz(n) < k) return 10000000000ll;
  if (sz(n) == 1 || 1 + sz(n->l) == k) return n->val;
  if (sz(n->l) >= k)
    return findKth(n->l, k);
  else
    return findKth(n->r, k - sz(n->l) - 1);
}
int lessT(pnode n, int k) {
  if (!n) return 0;
  if (n->val >= k)
    return lessT(n->l, k);
  else
    return 1 + sz(n->l) + lessT(n->r, k);
}
int greaterT(pnode n, int k) {
  if (!n) return 0;
  if (n->val <= k)
    return greaterT(n->r, k);
  else
    return 1 + sz(n->r) + greaterT(n->l, k);
}
pnode tree[4 * N];
void print(pnode n) {
  if (!n) return;
  cout << n->val << " ";
  print(n->l);
  print(n->r);
}
void upd(int i, int s, int e, int p, int v, bool f) {
  if (s > p || e < p) return;
  if (f) {
    insert(tree[i], init(v));
  } else {
    erase(tree[i], v);
  }
  if (s >= p && e <= p) return;
  int mid = (s + e) >> 1;
  upd(i << 1, s, mid, p, v, f);
  upd(i << 1 | 1, mid + 1, e, p, v, f);
}
int qur(int i, int s, int e, int s1, int e1, int v, bool f) {
  if (s > e1 || e < s1) return 0;
  if (s >= s1 && e <= e1) {
    return f ? greaterT(tree[i], v) : lessT(tree[i], v);
  }
  int mid = (s + e) >> 1;
  return qur(i << 1, s, mid, s1, e1, v, f) +
         qur(i << 1 | 1, mid + 1, e, s1, e1, v, f);
}
int a[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  long long res = 0;
  memset(tree, 0, sizeof tree);
  for (int i = 0; i < n; i++) {
    a[i] = i;
    upd(1, 0, n - 1, i, i, 1);
  }
  int x, y;
  while (m--) {
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    x--;
    y--;
    if (a[x] > a[y])
      res--;
    else if (a[x] < a[y])
      res++;
    if (y - x > 1) {
      res -= qur(1, 0, n - 1, x + 1, y - 1, a[x], 0);
      res += qur(1, 0, n - 1, x + 1, y - 1, a[x], 1);
      res -= qur(1, 0, n - 1, x + 1, y - 1, a[y], 1);
      res += qur(1, 0, n - 1, x + 1, y - 1, a[y], 0);
    }
    upd(1, 0, n - 1, x, a[x], 0);
    upd(1, 0, n - 1, x, a[y], 1);
    upd(1, 0, n - 1, y, a[y], 0);
    upd(1, 0, n - 1, y, a[x], 1);
    swap(a[x], a[y]);
    printf("%I64d\n", res);
  }
}