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>
template <typename T>
void scan(T &x) {
  x = 0;
  bool _ = 0;
  T c = getchar();
  _ = c == 45;
  c = _ ? getchar() : c;
  while (c < 48 || c > 57) c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15);
  x = _ ? -x : x;
}
template <typename T>
void printn(T n) {
  bool _ = 0;
  _ = n < 0;
  n = _ ? -n : n;
  char snum[65];
  int i = 0;
  do {
    snum[i++] = n % 10 + 48;
    n /= 10;
  } while (n);
  --i;
  if (_) putchar(45);
  while (i >= 0) putchar(snum[i--]);
}
template <typename First, typename... Ints>
void scan(First &arg, Ints &...rest) {
  scan(arg);
  scan(rest...);
}
template <typename T>
void print(T n) {
  printn(n);
  putchar(10);
}
template <typename First, typename... Ints>
void print(First arg, Ints... rest) {
  printn(arg);
  putchar(32);
  print(rest...);
}
using namespace std;
const int MM = 8e5 + 5;
int n, k, m;
set<pair<int, int>> in;
multiset<int> st;
struct node {
  int val, lp;
  void apply(int v) {
    val += v;
    lp += v;
  }
};
struct segtree {
  node tree[MM * 4];
  int DEF = 0;
  int merge(int va, int vb) { return max(va, vb); }
  void push_up(int rt) {
    tree[rt].val = merge(tree[(rt << 1)].val, tree[(rt << 1 | 1)].val);
  }
  void push_down(int rt, int nl, int nr) {
    int &val = tree[rt].lp;
    if (nl != nr) {
      tree[(rt << 1)].apply(val);
      tree[(rt << 1 | 1)].apply(val);
    }
    val = DEF;
  }
  void build(int l, int r, int rt) {
    int nl = l, nr = r;
    if (l == r) {
      tree[rt].val = l;
      tree[rt].lp = 0;
      return;
    }
    build(l, ((nl + nr) >> 1), (rt << 1));
    build(((nl + nr) >> 1) + 1, r, (rt << 1 | 1));
    push_up(rt);
  }
  void build() { build(0, MM - 1, 1); }
  void update(int l, int r, int val, int nl, int nr, int rt) {
    if (r < nl || l > nr) return;
    if (l <= nl && r >= nr) {
      tree[rt].apply(val);
      return;
    }
    push_down(rt, nl, nr);
    update(l, r, val, nl, ((nl + nr) >> 1), (rt << 1));
    update(l, r, val, ((nl + nr) >> 1) + 1, nr, (rt << 1 | 1));
    push_up(rt);
  }
  void update(int l, int r, int val) { update(l, r, val, 0, MM - 1, 1); }
  int query(int l, int r, int nl, int nr, int rt) {
    if (r < nl || l > nr) return DEF;
    if (l <= nl && r >= nr) return tree[rt].val;
    push_down(rt, nl, nr);
    return merge(query(l, r, nl, ((nl + nr) >> 1), (rt << 1)),
                 query(l, r, ((nl + nr) >> 1) + 1, nr, (rt << 1 | 1)));
  }
  int query(int l, int r) { return query(l, r, 0, MM - 1, 1); }
} ST;
int main() {
  scan(n, k, m);
  ST.build();
  while (m--) {
    int x, y;
    scan(x, y);
    if (in.count({x, y})) {
      in.erase({x, y});
      y += abs(x - k);
      st.erase(st.lower_bound(y));
      ST.update(1, y, -1);
    } else {
      in.insert({x, y});
      y += abs(x - k);
      st.insert(y);
      ST.update(1, y, 1);
    }
    int mx = st.size() ? *--st.end() : 1;
    print(max(0, ST.query(1, mx) - 1 - n));
  }
}