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 = 200000 + 5;
struct SegTree {
  int mx, ad;
} t[(maxN * 2) << 2];
int cnt[maxN * 2];
int n, k, m;
set<pair<int, int> > s;
set<int> s2;
void pushup(int u) { t[u].mx = max(t[u << 1].mx, t[u << 1 | 1].mx); }
void pushdown(int u) {
  if (t[u].ad != 0) {
    t[u << 1].mx += t[u].ad;
    t[u << 1 | 1].mx += t[u].ad;
    t[u << 1].ad += t[u].ad;
    t[u << 1 | 1].ad += t[u].ad;
    t[u].ad = 0;
  }
}
void build(int u, int l, int r) {
  if (l == r) {
    t[u].mx = l - n;
    return;
  }
  int m = (l + r) >> 1;
  build(u << 1, l, m);
  build(u << 1 | 1, m + 1, r);
  pushup(u);
}
void update(int u, int l, int r, int ul, int ur, int val) {
  if (ul <= l && r <= ur) {
    t[u].mx += val;
    t[u].ad += val;
    return;
  }
  pushdown(u);
  int m = (l + r) >> 1;
  if (ul <= m) update(u << 1, l, m, ul, ur, val);
  if (ur > m) update(u << 1 | 1, m + 1, r, ul, ur, val);
  pushup(u);
}
int query(int u, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return t[u].mx;
  if (qr < l || ql > r) return 0;
  pushdown(u);
  int m = (l + r) >> 1;
  return max(query(u << 1, l, m, ql, qr), query(u << 1 | 1, m + 1, r, ql, qr));
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  build(1, 0, n * 2);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int val = 1, row = abs(x - k) + y - 1;
    set<pair<int, int> >::iterator it = s.find(make_pair(x, y));
    if (it != s.end()) {
      s.erase(it);
      val = -1;
      --cnt[row];
      if (!cnt[row]) s2.erase(row);
    } else {
      s.insert(make_pair(x, y));
      ++cnt[row];
      if (cnt[row] == 1) s2.insert(row);
    }
    update(1, 0, n * 2, 0, row, val);
    if (!s2.empty())
      printf("%d\n", max(query(1, 0, n * 2, 0, *s2.rbegin()), 0));
    else
      printf("0\n");
  }
  return 0;
}