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 next_x[8] = {0, 1, -1, 0, 1, 1, -1, -1};
const int next_y[8] = {1, 0, 0, -1, 1, -1, -1, 1};
const int inf = 1e9 + 5;
const long long linf = 1e18;
const double PI = acos(-1.0);
const int MAXN = 2e5 + 5;
const int N = 1e6 + 5;
int n, m, k, cnt = 0;
int mx[N * 4], add[N * 4];
set<pair<int, int> > s;
multiset<int> t;
void doadd(int cnt, int v) { add[cnt] += v, mx[cnt] += v; }
void up(int cnt) { mx[cnt] = max(mx[((cnt << 1))], mx[((cnt << 1 | 1))]); }
void down(int cnt) {
  if (add[cnt]) {
    doadd(((cnt << 1)), add[cnt]);
    doadd(((cnt << 1 | 1)), add[cnt]);
    add[cnt] = 0;
  }
}
void update(int l, int r, int nl, int nr, int v, int cnt) {
  if (l == nl && r == nr) {
    doadd(cnt, v);
    return;
  }
  down(cnt);
  if (nr <= ((l + r) / 2))
    update(l, ((l + r) / 2), nl, nr, v, ((cnt << 1)));
  else if (nl > ((l + r) / 2))
    update(((l + r) / 2) + 1, r, nl, nr, v, ((cnt << 1 | 1)));
  else
    update(l, ((l + r) / 2), nl, ((l + r) / 2), v, ((cnt << 1))),
        update(((l + r) / 2) + 1, r, ((l + r) / 2) + 1, nr, v,
               ((cnt << 1 | 1)));
  up(cnt);
}
void build(int l, int r, int cnt) {
  if (l == r) {
    mx[cnt] = l - 1;
    return;
  }
  build(l, ((l + r) / 2), ((cnt << 1))),
      build(((l + r) / 2) + 1, r, ((cnt << 1 | 1))), up(cnt);
}
int query(int l, int r, int nl, int nr, int cnt) {
  if (l == nl && r == nr) return mx[cnt];
  down(cnt);
  if (nr <= ((l + r) / 2)) return query(l, ((l + r) / 2), nl, nr, ((cnt << 1)));
  if (nl > ((l + r) / 2))
    return query(((l + r) / 2) + 1, r, nl, nr, ((cnt << 1 | 1)));
  return max(
      query(l, ((l + r) / 2), nl, ((l + r) / 2), ((cnt << 1))),
      query(((l + r) / 2) + 1, r, ((l + r) / 2) + 1, nr, ((cnt << 1 | 1))));
}
int work() {
  scanf("%d%d%d", &n, &k, &m), build(1, N, 1);
  while (m--) {
    pair<int, int> p;
    scanf("%d%d", &p.first, &p.second);
    int pos = abs(k - p.first) + p.second, f;
    if (s.find(p) == s.end())
      s.insert(p), f = 1, t.insert(pos);
    else
      s.erase(p), f = -1, t.erase(t.find(pos));
    update(1, N, 1, pos, f, 1);
    if (t.empty()) {
      printf("0\n");
      continue;
    }
    int l = max(n, *t.rbegin()), r = N, ans = r;
    while (l <= r) {
      if (query(1, N, 1, ((l + r) / 2), 1) <= ((l + r) / 2))
        ans = ((l + r) / 2), r = ((l + r) / 2) - 1;
      else
        l = ((l + r) / 2) + 1;
    }
    printf("%d\n", max(0, ans - n));
  }
  return 0;
}
int main() {
  work();
  return 0;
}