#include <bits/stdc++.h>
using namespace std;
int N, B, Q;
int a[200005];
vector<int> adj[200005];
void init() {
  B = sqrt(N);
  for (int i = 1; i <= N; i++) {
    a[i] = i;
    adj[i / B].push_back(i);
  }
}
long long work(int l, int r) {
  if (l == r) return 0;
  int idx, idy, x, y, k;
  x = a[l];
  y = a[r];
  idx = l / B;
  k = find(adj[idx].begin(), adj[idx].end(), x) - adj[idx].begin();
  adj[idx][k] = y;
  sort(adj[idx].begin(), adj[idx].end());
  idy = r / B;
  k = find(adj[idy].begin(), adj[idy].end(), y) - adj[idy].begin();
  adj[idy][k] = x;
  sort(adj[idy].begin(), adj[idy].end());
  int ans = 0, f;
  if (x > y)
    f = -1, swap(x, y);
  else
    f = 1;
  if (idx == idy) {
    for (int i = l + 1; i <= r - 1; i++) {
      if (x < a[i] && a[i] < y) ++ans;
    }
  } else {
    for (int i = l + 1; i < (idx + 1) * B; i++) {
      if (x < a[i] && a[i] < y) ++ans;
    }
    for (int id = idx + 1; id < idy; id++) {
      ans += upper_bound(adj[id].begin(), adj[id].end(), y) -
             lower_bound(adj[id].begin(), adj[id].end(), x);
    }
    for (int i = idy * B; i < r; i++) {
      if (x < a[i] && a[i] < y) ++ans;
    }
  }
  swap(a[l], a[r]);
  return (2 * ans + 1) * f;
}
int main() {
  scanf("%d%d", &N, &Q);
  init();
  int l, r;
  long long ans = 0;
  while (Q--) {
    scanf("%d%d", &l, &r);
    if (l > r) swap(l, r);
    ans += work(l, r);
    printf("%lld\n", ans);
  }
  return 0;
}
