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 NEUTRAL_VAL = -1000000000;
struct SegmentTreeNode {
  int val;
  int delay_val;
  SegmentTreeNode(int _val = NEUTRAL_VAL) : val(_val), delay_val(0) {}
  SegmentTreeNode operator+(const SegmentTreeNode& R) const {
    SegmentTreeNode res;
    res.val = max(this->val, R.val);
    return res;
  }
  void update(int L, int R, int d) {
    delay_val += d;
    val += d;
  }
  void propagate(SegmentTreeNode& pL, SegmentTreeNode& pR, int L, int R) {
    if (delay_val != 0) {
      pL.update(L, (L + R) / 2, delay_val);
      pR.update((L + R) / 2 + 1, R, delay_val);
      delay_val = 0;
    }
  }
};
class SegmentTree {
  int N;
  vector<SegmentTreeNode> tree;
  void _build(const vector<int>& A, int node, int L, int R) {
    if (L == R) {
      tree[node] = SegmentTreeNode(A[L]);
      return;
    }
    _build(A, 2 * node, L, (L + R) / 2);
    _build(A, 2 * node + 1, (L + R) / 2 + 1, R);
    tree[node] = tree[2 * node] + tree[2 * node + 1];
  }
  void _update(int p, int q, int val, int node, int L, int R) {
    if (q < L || p > R) return;
    if (p <= L && R <= q) {
      tree[node].update(L, R, val);
      return;
    }
    tree[node].propagate(tree[2 * node], tree[2 * node + 1], L, R);
    _update(p, q, val, 2 * node, L, (L + R) / 2);
    _update(p, q, val, 2 * node + 1, (L + R) / 2 + 1, R);
    tree[node] = tree[2 * node] + tree[2 * node + 1];
  }
  SegmentTreeNode _query(int p, int q, int node, int L, int R) {
    if (q < L || p > R) return SegmentTreeNode();
    if (p <= L && R <= q) return tree[node];
    tree[node].propagate(tree[2 * node], tree[2 * node + 1], L, R);
    SegmentTreeNode resL = _query(p, q, 2 * node, L, (L + R) / 2);
    SegmentTreeNode resR = _query(p, q, 2 * node + 1, (L + R) / 2 + 1, R);
    return resL + resR;
  }

 public:
  SegmentTree(const vector<int>& A) {
    N = A.size();
    int NUM_NODES = 4 * N + 1;
    tree = vector<SegmentTreeNode>(NUM_NODES);
    _build(A, 1, 0, N - 1);
  }
  void update(int p, int q, int val) { _update(p, q, val, 1, 0, N - 1); }
  int query(int p, int q) { return _query(p, q, 1, 0, N - 1).val; }
};
int K;
struct Pos {
  int x, y, y_idx;
  Pos(int _x, int _y) : x(_x), y(_y), y_idx(_y + abs(K - _x)) {}
  bool operator<(const Pos p) const {
    if (y_idx != p.y_idx) return y_idx > p.y_idx;
    if (x != p.x) return x < p.x;
    return y < p.y;
  }
};
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> K >> M;
  --K;
  vector<int> space(2 * N);
  for (int i = 0; i < 2 * N; ++i) space[i] = -(N - i);
  ;
  SegmentTree st(space);
  set<Pos> pawns;
  for (int m = (1), _b = (M); m <= _b; ++m) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    Pos p(x, y);
    ;
    if (pawns.erase(p)) {
      st.update(0, p.y_idx, -1);
    } else {
      pawns.insert(p);
      st.update(0, p.y_idx, +1);
    }
    int res;
    if (pawns.empty())
      res = 0;
    else
      res = max(st.query(0, pawns.begin()->y_idx), 0);
    cout << res << '\n';
  }
  return 0;
}