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;
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(int x);
inline void writeWord(const char *s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) c = getChar();
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
const int MAX_MEM = 1.3e8;
int mpos = 0;
char mem[MAX_MEM];
inline void *operator new(size_t n) {
  char *res = mem + mpos;
  mpos += n;
  return (void *)res;
}
inline void operator delete(void *) {}
const int N = 2e5 + 1;
long long A = 13, B = 19, X = 223, Y = 239, Z = 97, MOD = 1e9 + 993;
long long myrand() {
  long long C = (A * X + B * Y + Z) % MOD;
  A = B;
  B = C;
  return A;
}
struct treap {
  treap *l, *r;
  int x, y;
  int sz, cnt;
  treap(int x) : x(x), y(myrand()), sz(1), cnt(1), l(0), r(0) {}
  treap() {}
};
inline void recalc(treap *t) {
  if (!t) {
    return;
  }
  t->sz = t->cnt;
  if (t->l) {
    t->sz += t->l->sz;
  }
  if (t->r) {
    t->sz += t->r->sz;
  }
}
inline pair<treap *, treap *> split(treap *t, int x) {
  if (!t) {
    return {0, 0};
  }
  if (x < t->x) {
    recalc(t);
    auto a = split(t->l, x);
    t->l = a.second;
    recalc(t);
    recalc(a.first);
    return {a.first, t};
  } else {
    recalc(t);
    auto a = split(t->r, x);
    t->r = a.first;
    recalc(t);
    recalc(a.second);
    return {t, a.second};
  }
}
inline treap *merge(treap *l, treap *r) {
  if (!l) {
    return r;
  }
  if (!r) {
    return l;
  }
  if (l->y > r->y) {
    recalc(l);
    recalc(r);
    l->r = merge(l->r, r);
    recalc(l);
    return l;
  } else {
    recalc(l);
    recalc(r);
    r->l = merge(l, r->l);
    recalc(r);
    return r;
  }
}
inline int get_val(treap *t) {
  if (!t) {
    return 0;
  }
  recalc(t);
  return t->sz;
}
inline treap *del(treap *&t, int x) {
  if (t->x == x) {
    if (t->cnt == 1) {
      t = merge(t->l, t->r);
    } else {
      t->cnt--;
      recalc(t);
    }
    return t;
  } else if (x < t->x) {
    t->l = del(t->l, x);
    recalc(t);
    return t;
  } else {
    t->r = del(t->r, x);
    recalc(t);
    return t;
  }
}
inline void insert(treap *&t, treap *x) {
  if (!t) {
    t = x;
    return;
  }
  if (x->y > t->y) {
    auto a = split(t, x->x);
    x->l = a.first;
    x->r = a.second;
    t = x;
    recalc(t);
  } else {
    if (x->x < t->x) {
      insert(t->l, x);
    } else {
      insert(t->r, x);
    }
    recalc(t);
  }
}
bool check(treap *t, int x) {
  if (!t) {
    return 0;
  }
  if (t->x == x) {
    t->cnt++;
    recalc(t);
    return true;
  } else if (x < t->x) {
    bool lel = check(t->l, x);
    recalc(t);
    return lel;
  } else {
    bool lel = check(t->r, x);
    recalc(t);
    return lel;
  }
}
inline void add(treap *&t, int x) {
  if (check(t, x)) {
    return;
  }
  insert(t, new treap(x));
}
inline int get(treap *&t, int l, int r) {
  auto a = split(t, r);
  auto b = split(a.first, l - 1);
  int kek = get_val(b.second);
  a.first = merge(b.first, b.second);
  t = merge(a.first, a.second);
  return kek;
}
treap *fenw[N];
inline void upd(int x, int y) {
  for (; x < N; x = (x | (x + 1))) {
    add(fenw[x], y);
  }
}
inline void nopd(int x, int y) {
  for (; x < N; x = (x | (x + 1))) {
    fenw[x] = del(fenw[x], y);
  }
}
inline int get(int x, int l, int r) {
  int res = 0;
  for (; x >= 0; x = (x & (x + 1)) - 1) {
    res += get(fenw[x], l, r);
  }
  return res;
}
inline int get(int x1, int x2, int y1, int y2) {
  x2--, y2--;
  return get(x2, y1, y2) - get(x1 - 1, y1, y2);
}
int main() {
  srand('M' + 'R' + '.' + 'D' + 'U' + 'D' + 'E' + 'C');
  int n = readInt(), q = readInt();
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    a[i] = i;
    upd(i, a[i]);
  }
  long long res = 0;
  for (int i = 0; i < q; i++) {
    int l = readInt(), r = readInt();
    l--, r--;
    if (l > r) {
      swap(l, r);
    }
    if (l != r) {
      res -= get(l, r + 1, 0, a[l]);
      res -= get(l, r + 1, a[r] + 1, n);
      res += (a[min(l, r)] > a[max(l, r)]);
      nopd(l, a[l]);
      nopd(r, a[r]);
      swap(a[l], a[r]);
      upd(l, a[l]);
      upd(r, a[r]);
      res += get(l, r + 1, a[r] + 1, n);
      res += get(l, r + 1, 0, a[l]);
      res -= (a[min(l, r)] > a[max(l, r)]);
    }
    writeInt(res, '\n');
  }
}