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 int MAXN = 2e5 + 9;
struct TREE_NODE {
  int sum;
  int lz = 0;
};
TREE_NODE tree[8 * MAXN];
int cnt[2 * MAXN];
inline void build(int l, int r, int i = 1) {
  if (l == r - 1)
    tree[i].sum = l;
  else {
    int mid = (l + r) / 2;
    build(l, mid, 2 * i + 1);
    build(mid, r, 2 * i + 2);
    tree[i].sum = max(tree[2 * i + 1].sum, tree[2 * i + 2].sum);
  }
}
inline void push_down(int l, int r, int i) {
  if (r - l != 1 && tree[i].lz) {
    tree[i * 2 + 1].lz += tree[i].lz;
    tree[i * 2 + 2].lz += tree[i].lz;
    tree[i * 2 + 1].sum += tree[i].lz;
    tree[i * 2 + 2].sum += tree[i].lz;
    tree[i].lz = 0;
  }
}
inline int search(int l, int r, int L, int R, int i) {
  if (L >= R) return 0;
  if (l == L && r == R) return tree[i].sum;
  push_down(l, r, i);
  int mid = (l + r) / 2;
  return max(search(l, mid, L, min(R, mid), i * 2 + 1),
             search(mid, r, max(L, mid), R, i * 2 + 2));
}
inline void add(int l, int r, int L, int R, int n, int i) {
  if (L >= R) return;
  if (l == L && r == R) {
    tree[i].sum += n;
    tree[i].lz += n;
  } else {
    push_down(l, r, i);
    int mid = (l + r) / 2;
    add(l, mid, L, min(R, mid), n, i * 2 + 1);
    add(mid, r, max(L, mid), R, n, i * 2 + 2);
    tree[i].sum = max(tree[i * 2 + 1].sum, tree[i * 2 + 2].sum);
  }
}
int main() {
  int n, k, m, x, y;
  scanf("%d%d%d", &n, &k, &m);
  build(0, 2 * n, 0);
  set<int> pos_r;
  set<pair<int, int>> point_r;
  while (m--) {
    scanf("%d%d", &x, &y);
    int pos = abs(k - x) + y - 1;
    pair<int, int> p(x, y);
    if (point_r.find(p) != point_r.end()) {
      if (!(--cnt[pos])) pos_r.erase(pos);
      add(0, 2 * n, 0, pos + 1, -1, 0);
      point_r.erase(p);
    } else {
      if ((++cnt[pos]) == 1) pos_r.insert(pos);
      add(0, 2 * n, 0, pos + 1, 1, 0);
      point_r.insert(p);
    }
    if (pos_r.empty())
      printf("0\n");
    else
      printf("%d\n", max(0, search(0, 2 * n, 0, *pos_r.rbegin() + 1, 0) - n));
  }
}