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;
struct Node {
  Node *l = 0, *r = 0;
  int lo, hi, madd = 0;
  int maxVal = -1;
  int ourVal = 0;
  bool isFullZero = true;
  Node(int lo, int hi) : lo(lo), hi(hi) {}
  Node(vector<int>& v, int lo, int hi) : lo(lo), hi(hi) {
    if (lo + 1 < hi) {
      int mid = lo + (hi - lo) / 2;
      l = new Node(v, lo, mid);
      r = new Node(v, mid, hi);
      maxVal = max(l->maxVal, r->maxVal);
    } else
      maxVal = v[lo];
  }
  int query(int L, int R, bool print = false) {
    if (print) {
      cout << L << " " << R << " " << lo << " " << hi << " " << maxVal << "\n";
    }
    if (R <= lo || hi <= L) return -1;
    if (L <= lo && hi <= R) return maxVal;
    push();
    return max(l->query(L, R, print), r->query(L, R, print));
  }
  int findMaxPos() {
    if (hi == lo + 1) {
      if (ourVal > 0) {
        return lo;
      } else {
        return -1;
      }
    }
    if (!r->isFullZero) {
      return r->findMaxPos();
    } else {
      return l->findMaxPos();
    }
  }
  int findOur(int i) {
    if (i < lo || hi <= i) return -1;
    if (hi == lo + 1) {
      return ourVal;
    }
    int mid = lo + (hi - lo) / 2;
    if (i < mid)
      return l->findOur(i);
    else
      return r->findOur(i);
  }
  void addOur(int i, int x) {
    if (i < lo || hi <= i) return;
    if (hi == lo + 1) {
      ourVal += x;
      if (ourVal == 0)
        isFullZero = true;
      else
        isFullZero = false;
      return;
    }
    int mid = lo + (hi - lo) / 2;
    if (i < mid) {
      l->addOur(i, x);
    } else {
      r->addOur(i, x);
    }
    isFullZero = (l->isFullZero && r->isFullZero);
  }
  void add(int L, int R, int x) {
    if (R <= lo || hi <= L) return;
    if (L <= lo && hi <= R) {
      madd += x;
      maxVal += x;
    } else {
      push();
      l->add(L, R, x);
      r->add(L, R, x);
      maxVal = max(l->maxVal, r->maxVal);
    }
  }
  void push() {
    if (madd != 0) {
      l->add(lo, hi, madd), r->add(lo, hi, madd), madd = 0;
    }
  }
};
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  k--;
  vector<unordered_set<int>> filled(n, unordered_set<int>());
  vector<int> initialValues(n + n - 1);
  for (int i = 0; i < n + n - 1; i++) {
    initialValues[i] = i;
  }
  Node* v = new Node(initialValues, 0, n + n - 1);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    int pos = y + max(k - x, x - k);
    int toAdd = 1;
    if (filled[x].find(y) == filled[x].end()) {
      filled[x].insert(y);
    } else {
      toAdd = -1;
      filled[x].erase(y);
    }
    v->add(0, pos + 1, toAdd);
    v->addOur(pos, toAdd);
    int maxPos = v->findMaxPos();
    if (maxPos == -1) {
      cout << "0\n";
    } else {
      int res = v->query(0, maxPos + 1);
      cout << max(res - n, 0) << "\n";
    }
  }
}