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>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
__inline__ __attribute__((always_inline)) unsigned int rnd() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a >= 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) {
  return a < b ? b : a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) {
  return a < b ? a : b;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (b < a) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  char ch(getchar());
  bool f(false);
  while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (ch >= 48 && ch <= 57)
    x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  if (f) x = -x;
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 800005;
int n, k, m;
struct node {
  int a, b, ans;
  __inline__ __attribute__((always_inline)) node operator+(
      const node &o) const {
    int tmp = min(a, o.b);
    return (node){a + o.a - tmp, b + o.b - tmp, ans + o.ans + tmp};
  }
};
struct Node {
  int ls, rs;
  node val;
} f[N << 1];
int node_cnt;
__inline__ __attribute__((always_inline)) void PushUp(int x) {
  f[x].val = f[f[x].ls].val + f[f[x].rs].val;
}
int build(int l = 1, int r = n << 2) {
  int cur = ++node_cnt;
  if (l == r) {
    if (l & 1)
      f[cur].val = (node){0, 0, 0};
    else
      f[cur].val = (node){0, 1, 0};
    return cur;
  }
  int mid = (l + r) >> 1;
  f[cur].ls = build(l, mid);
  f[cur].rs = build(mid + 1, r);
  PushUp(cur);
  return cur;
}
void Update(int pos, int C, int l = 1, int r = n << 2, int cur = 1) {
  if (l == r) {
    f[cur].val.a += C;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    Update(pos, C, l, mid, f[cur].ls);
  else
    Update(pos, C, mid + 1, r, f[cur].rs);
  PushUp(cur);
}
node Query(int L, int R, int l = 1, int r = n << 2, int cur = 1) {
  if (L <= l && r <= R) return f[cur].val;
  int mid = (l + r) >> 1;
  if (L <= mid && R > mid)
    return Query(L, R, l, mid, f[cur].ls) + Query(L, R, mid + 1, r, f[cur].rs);
  return L <= mid ? Query(L, R, l, mid, f[cur].ls)
                  : Query(L, R, mid + 1, r, f[cur].rs);
}
std::set<std::pair<int, int> > S;
std::multiset<int> s;
int main() {
  read(n, k, m);
  build();
  int x, y;
  while (m--) {
    read(x, y);
    std::pair<int, int> tmp = std::make_pair(x, y);
    int qwq = y + abs(x - k);
    if (S.find(tmp) != S.end())
      Update(qwq * 2 - 1, -1), s.erase(s.find(qwq)), S.erase(tmp);
    else
      Update(qwq * 2 - 1, 1), s.insert(qwq), S.insert(tmp);
    if (s.empty()) {
      printf("0\n");
    } else {
      int tmp = max(n, *--s.end());
      printf("%d\n", tmp - n + ((int)s.size()) - Query(1, tmp * 2).ans);
    }
  }
  return 0;
}