Problem: You are given a chessboard consisting of n rows and n columns. Rows are numbered from bottom to top from 1 to n. Columns are numbered from left to right from 1 to n. The cell at the intersection of the x-th column and the y-th row is denoted as (x, y). Furthermore, the k-th column is a special column. 

Initially, the board is empty. There are m changes to the board. During the i-th change one pawn is added or removed from the board. The current board is good if we can move all pawns to the special column by the followings rules:

  * Pawn in the cell (x, y) can be moved to the cell (x, y + 1), (x - 1, y + 1) or (x + 1, y + 1); 
  * You can make as many such moves as you like; 
  * Pawns can not be moved outside the chessboard; 
  * Each cell can not contain more than one pawn. 



The current board may not always be good. To fix it, you can add new rows to the board. New rows are added at the top, i. e. they will have numbers n+1, n+2, n+3, ....

After each of m changes, print one integer — the minimum number of rows which you have to add to make the board good.

Input

The first line contains three integers n, k and m (1 ≤ n, m ≤ 2 ⋅ 10^5; 1 ≤ k ≤ n) — the size of the board, the index of the special column and the number of changes respectively.

Then m lines follow. The i-th line contains two integers x and y (1 ≤ x, y ≤ n) — the index of the column and the index of the row respectively. If there is no pawn in the cell (x, y), then you add a pawn to this cell, otherwise — you remove the pawn from this cell.

Output

After each change print one integer — the minimum number of rows which you have to add to make the board good.

Example

Input


5 3 5
4 4
3 5
2 4
3 4
3 5


Output


0
1
2
2
1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x1fffffffffffffff;
const double INFD = 1e20;
const double EPS = 1e-9;
const double PI = atan(1) * 4;
const long long M = 1000000007;
long long scan() {
  long long r;
  scanf("%lld", &r);
  return r;
}
void scanstr(char *buf) { scanf("%s", buf); }
struct Node {
  long long segLeft;
  long long segRight;
  long long base;
  long long value;
  long long pendingDiff;
  Node *leftChild;
  Node *rightChild;
};
Node *newNode(long long segLeft, long long segRight, long long base) {
  Node *result = new Node();
  result->segLeft = segLeft;
  result->segRight = segRight;
  result->base = base;
  result->value = base;
  result->pendingDiff = 0;
  result->leftChild = NULL;
  result->rightChild = NULL;
  return result;
}
bool ensureChildren(Node *root) {
  if (root == NULL) return false;
  if (root->segLeft == root->segRight) return false;
  if (root->leftChild != NULL) return true;
  long long separator = (root->segLeft + root->segRight) / 2;
  root->leftChild = newNode(root->segLeft, separator, root->base);
  root->rightChild = newNode(separator + 1, root->segRight, root->base);
  return true;
}
void update(Node *root, long long queryLeft, long long queryRight,
            long long diff);
void pushPending(Node *root) {
  if (!ensureChildren(root)) return;
  update(root->leftChild, root->segLeft, root->segRight, root->pendingDiff);
  update(root->rightChild, root->segLeft, root->segRight, root->pendingDiff);
  root->pendingDiff = 0;
}
void update(Node *root, long long queryLeft, long long queryRight,
            long long diff) {
  if (root == NULL) return;
  if (queryLeft > queryRight) return;
  if (queryLeft > root->segRight || queryRight < root->segLeft) return;
  if (queryLeft <= root->segLeft && queryRight >= root->segRight) {
    root->value += diff;
    root->pendingDiff += diff;
    return;
  }
  pushPending(root);
  update(root->leftChild, queryLeft, queryRight, diff);
  update(root->rightChild, queryLeft, queryRight, diff);
  root->value = max(root->leftChild->value, root->rightChild->value);
}
long long query(Node *root, long long queryLeft, long long queryRight) {
  if (root == NULL) return -INF;
  if (queryLeft > queryRight) return -INF;
  if (queryLeft > root->segRight || queryRight < root->segLeft) return -INF;
  if (queryLeft <= root->segLeft && queryRight >= root->segRight)
    return root->value;
  pushPending(root);
  long long subLeft = query(root->leftChild, queryLeft, queryRight);
  long long subRight = query(root->rightChild, queryLeft, queryRight);
  return max(subLeft, subRight);
}
void dumpTree(Node *root) {
  if (root == NULL) return;
  cout << "val[" << root->segLeft << "," << root->segRight
       << "]=" << root->value << endl;
  cout << "pen[" << root->segLeft << "," << root->segRight
       << "]=" << root->pendingDiff << endl;
  dumpTree(root->leftChild);
  dumpTree(root->rightChild);
}
int main() {
  long long n = scan();
  long long k = scan();
  long long m = scan();
  set<tuple<long long, long long> > pawns;
  map<long long, long long> slot;
  Node *segTree = newNode(1, 2 * n - 1, 0);
  for (long long i = 0; i < 2 * n - 1; ++i) {
    update(segTree, i + 1, i + 1, i);
  }
  for (long long i = 0; i < m; ++i) {
    long long x = scan();
    long long y = scan();
    long long b = y + abs(x - k);
    tuple<long long, long long> loc = make_tuple(x, y);
    if (pawns.find(loc) == pawns.end()) {
      pawns.insert(loc);
      slot[b]++;
      update(segTree, 1, b, 1);
    } else {
      pawns.erase(loc);
      slot[b]--;
      if (slot[b] == 0) {
        slot.erase(b);
      }
      update(segTree, 1, b, -1);
    }
    long long expected = 0;
    if (slot.size() == 0) {
      expected = 0;
    } else {
      long long lastSlotNumber = slot.rbegin()->first;
      expected = query(segTree, 1, lastSlotNumber);
    }
    long long ans = max(0LL, expected - n);
    cout << ans << endl;
  }
  return 0;
}