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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jialin Ouyang (Jialin.Ouyang@gmail.com)
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    QuickScanner in = new QuickScanner(inputStream);
    QuickWriter out = new QuickWriter(outputStream);
    TaskE solver = new TaskE();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskE {
    int n;
    int m;
    int sqrtN;
    int[] perm;
    int[] blockIdx;
    IntAddBinaryIndexedTree2D biTree;
    long res;

    public void solve(int testNumber, QuickScanner in, QuickWriter out) {
      n = in.nextInt();
      for (sqrtN = 1; sqrtN < n / sqrtN; ++sqrtN) {
      }
      perm = new int[n];
      blockIdx = new int[n];
      m = 0;
      for (int i = 0; i < n; i += sqrtN, ++m) {
        for (int j = i, k = 0; j < n && k < sqrtN; ++j, ++k) {
          perm[j] = j;
          blockIdx[j] = m;
//        biTree.update(m, i, 1);
        }
      }
//    blockSize = new int[m];
      biTree = new IntAddBinaryIndexedTree2D(m, n);
//    for (int i = 0; i < m; ++i) {
//      blockSize[i] = Math.min(n - i * sqrtN, sqrtN);
//    }
      for (int i = 0; i < n; ++i) biTree.update(blockIdx[i], i, 1);
      res = 0;
      for (int q = in.nextInt(); q > 0; --q) {
        int x = in.nextInt() - 1;
        int y = in.nextInt() - 1;
        out.println(calc(x, y));
      }
    }

    long calc(int x, int y) {
      if (x > y) return calc(y, x);
      if (x == y) return res;
      res += perm[x] > perm[y] ? -1 : 1;
      res -= subCalc(x, y);
//System.out.printf("subCalc(%d,%d):%d\n", x, y, subCalc(x, y));
      biTree.update(blockIdx[x], perm[x], -1);
      biTree.update(blockIdx[y], perm[y], -1);
      IntArrayUtils.swap(perm, x, y);
      biTree.update(blockIdx[x], perm[x], 1);
      biTree.update(blockIdx[y], perm[y], 1);
//System.out.printf("subCalc(%d,%d):%d\n", x, y, subCalc(x, y));
      res += subCalc(x, y);
      return res;
    }

    int subCalc(int x, int y) {
      int idxX = blockIdx[x], idxY = blockIdx[y];
      int valueX = perm[x], valueY = perm[y];
      int res = 0;
//System.out.printf("subCalc(%d,%d) idxX:%d idxY:%d\n", x, y, idxX, idxY);
      if (idxX + 1 < idxY) {
        res += biTree.calcRange(idxX + 1, 0, idxY, valueX);
        res += biTree.calcRange(idxX + 1, valueY + 1, idxY, n);
      }
//System.out.printf("\t%d\n", res);
      if (idxX == idxY) {
        for (int i = x + 1; i < y; ++i) {
          if (valueX > perm[i]) ++res;
          if (perm[i] > valueY) ++res;
        }
      } else {
        for (int i = Math.min((idxX + 1) * sqrtN, n) - 1; i > x; --i) {
          if (valueX > perm[i]) ++res;
          if (perm[i] > valueY) ++res;
        }
        for (int i = sqrtN * idxY; i < y; ++i) {
          if (valueX > perm[i]) ++res;
          if (perm[i] > valueY) ++res;
        }
      }
//System.out.printf("\t%d\n", res);
      return res;
    }

  }

  static abstract class AbstractIntBinaryIndexedTree2D {
    private int n;
    private int m;
    private int[][] values;

    public AbstractIntBinaryIndexedTree2D(int capacity1, int capacity2) {
      values = new int[capacity1][capacity2];
    }

    public abstract int merge(int x, int y);

    public void init(int n, int m, int initValue) {
      this.n = n;
      this.m = m;
      for (int i = 0; i < n; ++i) {
        Arrays.fill(values[i], 0, m, initValue);
      }
    }

    public void update(int x, int y, int value) {
      for (; x < n; x |= x + 1)
        for (int i = y; i < m; i |= i + 1) {
          values[x][i] = merge(values[x][i], value);
        }
    }

    public int calc(int x, int y, int initValue) {
      int res = initValue;
      for (; x >= 0; x = (x & (x + 1)) - 1)
        for (int i = y; i >= 0; i = (i & (i + 1)) - 1) {
          res = merge(res, values[x][i]);
        }
      return res;
    }

  }

  static class QuickWriter {
    private final PrintWriter writer;

    public QuickWriter(OutputStream outputStream) {
      this.writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public QuickWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; ++i) {
        if (i > 0) {
          writer.print(' ');
        }
        writer.print(objects[i]);
      }
    }

    public void println(Object... objects) {
      print(objects);
      writer.print('\n');
    }

    public void close() {
      writer.close();
    }

  }

  static class IntAddBinaryIndexedTree2D extends AbstractIntBinaryIndexedTree2D {
    public IntAddBinaryIndexedTree2D(int capacity1, int capacity2) {
      super(capacity1, capacity2);
      init(capacity1, capacity2);
    }


    public int merge(int x, int y) {
      return x + y;
    }


    public void init(int n, int m, int initValue) {
      throw new UnsupportedOperationException();
    }


    public int calc(int x, int y, int initValue) {
      throw new UnsupportedOperationException();
    }

    public void init(int n, int m) {
      super.init(n, m, 0);
    }

    public int calc(int x, int y) {
      return super.calc(x, y, 0);
    }

    public int calcRange(int x1, int y1, int x2, int y2) {
      if (x1 >= x2 || y1 >= y2) return 0;
      int res = calc(x2 - 1, y2 - 1);
      if (x1 > 0) res -= calc(x1 - 1, y2 - 1);
      if (y1 > 0) res -= calc(x2 - 1, y1 - 1);
      if (x1 > 0 && y1 > 0) res += calc(x1 - 1, y1 - 1);
      return res;
    }

  }

  static class IntArrayUtils {
    public static void swap(int[] values, int uIdx, int vIdx) {
      if (uIdx == vIdx) return;
      values[uIdx] ^= values[vIdx];
      values[vIdx] ^= values[uIdx];
      values[uIdx] ^= values[vIdx];
    }

  }

  static class QuickScanner {
    private static final int BUFFER_SIZE = 1024;
    private InputStream stream;
    private byte[] buffer;
    private int currentPosition;
    private int numberOfChars;

    public QuickScanner(InputStream stream) {
      this.stream = stream;
      this.buffer = new byte[BUFFER_SIZE];
      this.currentPosition = 0;
      this.numberOfChars = 0;
    }

    public int nextInt() {
      int c = nextNonSpaceChar();
      boolean positive = true;
      if (c == '-') {
        positive = false;
        c = nextChar();
      }
      int res = 0;
      do {
        if (c < '0' || '9' < c) throw new RuntimeException();
        res = res * 10 + c - '0';
        c = nextChar();
      } while (!isSpaceChar(c));
      return positive ? res : -res;
    }

    public int nextNonSpaceChar() {
      int res = nextChar();
      for (; isSpaceChar(res) || res < 0; res = nextChar()) ;
      return res;
    }

    public int nextChar() {
      if (numberOfChars == -1) {
        throw new RuntimeException();
      }
      if (currentPosition >= numberOfChars) {
        currentPosition = 0;
        try {
          numberOfChars = stream.read(buffer);
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
        if (numberOfChars <= 0) {
          return -1;
        }
      }
      return buffer[currentPosition++];
    }

    public boolean isSpaceChar(int c) {
      return c == ' ' || c == '\t' || isEndOfLineChar(c);
    }

    public boolean isEndOfLineChar(int c) {
      return c == '\n' || c == '\r' || c < 0;
    }

  }
}

