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>
#pragma GCC optimize("Ofast,inline,unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,avx,avx2,abm,mmx,popcnt,tune=native")
using i64 = long long;
namespace IO {
char buf[1000000], *pa, *pb, pbuf[3000000], *pp = pbuf, stack_IO[21];
inline int read() {
  register int s = 0;
  register char c =
      pa == pb && (pb = (pa = buf) + fread(buf, 1, 1000000, stdin), pa == pb)
          ? EOF
          : *pa++;
  while (c != '-' && (c < '0' || c > '9'))
    c = pa == pb && (pb = (pa = buf) + fread(buf, 1, 1000000, stdin), pa == pb)
            ? EOF
            : *pa++;
  register int f = c == '-'
      ? c = pa == pb &&
                    (pb = (pa = buf) + fread(buf, 1, 1000000, stdin), pa == pb)
                ? EOF
                : *pa++,
               -1 : 1;
  while (c >= '0' && c <= '9')
    s = s * 10 + c - 48,
    c = pa == pb && (pb = (pa = buf) + fread(buf, 1, 1000000, stdin), pa == pb)
            ? EOF
            : *pa++;
  return s * f;
}
template <typename T>
inline void write(register T x, register char c = '\n') {
  if (x == 0) {
    *pp++ = 48, *pp++ = c;
    return;
  }
  if (x < 0) *pp++ = '-', x = ~x + 1;
  register char *top = stack_IO;
  while (x != 0) *top++ = x % 10 + 48, x /= 10;
  while (top != stack_IO) *pp++ = *--top;
  *pp++ = c;
}
void flush() { fwrite(pbuf, 1, pp - pbuf, stdout); }
template <typename T>
inline T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
inline int sgn(T x) {
  return x > 0 ? 1 : x < 0 ? -1 : 0;
}
template <typename T>
inline T min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
inline T max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
inline void swap(T &x, T &y) {
  T tmp = x;
  x = y, y = tmp;
}
}  // namespace IO
using namespace IO;
const int MAXN = 200000, MAXQ = 50000;
int n, Q;
int seq[MAXN + 7];
namespace TIT {
struct SMT {
  struct Node {
    int siz;
    Node *left, *right;
    Node() {}
    Node(int _siz) : siz(_siz), left(NULL), right(NULL) {}
  } * root;
  void insert(int L, int X, int l, int r, Node *&now) {
    if (now == NULL) now = new Node(0);
    now->siz += X;
    if (l == r) return;
    int mid = (l + r) >> 1;
    if (L <= mid)
      insert(L, X, l, mid, now->left);
    else
      insert(L, X, mid + 1, r, now->right);
  }
  void insert(int L, int X) { insert(L, X, 1, n, root); }
  int Count_Num(int L, int R, int l, int r, Node *now) {
    if (now == NULL) return 0;
    if (L <= l && r <= R) return now->siz;
    int mid = (l + r) >> 1;
    int res = 0;
    if (L <= mid) res += Count_Num(L, R, l, mid, now->left);
    if (mid < R) res += Count_Num(L, R, mid + 1, r, now->right);
    return res;
  }
  int Count_Num(int L, int R) { return Count_Num(L, R, 1, n, root); }
};
struct BIT {
  SMT smt[MAXN + 7];
  inline int lowbit(int x) { return x & (~x + 1); }
  void insert(int L, int X) {
    for (int i = L; i <= n; i += lowbit(i)) {
      smt[i].insert(X, 1);
    }
  }
  void erase(int L, int X) {
    for (int i = L; i <= n; i += lowbit(i)) {
      smt[i].insert(X, -1);
    }
  }
  int Count_Num(int L, int R, int LX, int RX) {
    if (L > R || LX > RX) return 0;
    int res = 0;
    for (int i = R; i >= 1; i -= lowbit(i)) res += smt[i].Count_Num(LX, RX);
    for (int i = L - 1; i >= 1; i -= lowbit(i)) res -= smt[i].Count_Num(LX, RX);
    return res;
  }
} bit;
void build() {
  for (int i = 1; i <= n; ++i) {
    bit.insert(i, i);
  }
}
}  // namespace TIT
void input() {
  n = read(), Q = read();
  for (register int i = 1; i <= n; ++i) {
    seq[i] = i;
  }
  TIT::build();
}
void solve() {
  i64 res = 0;
  while (Q--) {
    int l = read(), r = read();
    res -= TIT::bit.Count_Num(1, l - 1, seq[l] + 1, n);
    res -= TIT::bit.Count_Num(l + 1, n, 1, seq[l] - 1);
    TIT::bit.erase(l, seq[l]);
    res -= TIT::bit.Count_Num(1, r - 1, seq[r] + 1, n);
    res -= TIT::bit.Count_Num(r + 1, n, 1, seq[r] - 1);
    TIT::bit.erase(r, seq[r]);
    swap(seq[l], seq[r]);
    res += TIT::bit.Count_Num(1, l - 1, seq[l] + 1, n);
    res += TIT::bit.Count_Num(l + 1, n, 1, seq[l] - 1);
    TIT::bit.insert(l, seq[l]);
    res += TIT::bit.Count_Num(1, r - 1, seq[r] + 1, n);
    res += TIT::bit.Count_Num(r + 1, n, 1, seq[r] - 1);
    TIT::bit.insert(r, seq[r]);
    write(res);
  }
}
void Main() {
  input();
  solve();
  flush();
}
int main() {
  Main();
  return 0;
}