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>
class SegmentTree {
  struct node {
    int add, cap;
    bool empty;
    node(int v = -1) {
      if (v == -1) {
        add = cap = 0;
        empty = true;
      } else {
        add = v - 1;
        cap = 0;
        empty = !v;
      }
    }
    node(int add_, int cap_, bool empty_) {
      add = add_;
      cap = cap_;
      empty = empty_;
    }
    node operator+(node arg) {
      if (arg.empty) return node(add + arg.add, cap, empty);
      return node(std::max(add - arg.cap, 0) + arg.add,
                  cap + std::max(arg.cap - add, 0), false);
    }
    int get() { return add; }
  };
  std::vector<node> t;

 public:
  SegmentTree(int size) { t.resize((1 << 33 - __builtin_clz(size - 1)) - 1); }
  void build(int v, int tl, int tr, int init);
  void update(int v, int tl, int tr, int i, int x);
  node query(int v, int tl, int tr, int l, int r);
  int get();
};
void SegmentTree::build(int v, int tl, int tr, int init) {
  if (tr - tl == 1)
    t[v] = node(init);
  else {
    int m = (tl + tr) >> 1;
    build((v << 1) + 1, tl, m, init);
    build((v << 1) + 2, m, tr, init);
    t[v] = t[(v << 1) + 1] + t[(v << 1) + 2];
  }
}
void SegmentTree::update(int v, int tl, int tr, int i, int x) {
  if (tr - tl == 1)
    t[v] = node(x);
  else {
    int m = (tl + tr) >> 1;
    if (i < m)
      update((v << 1) + 1, tl, m, i, x);
    else
      update((v << 1) + 2, m, tr, i, x);
    t[v] = t[(v << 1) + 1] + t[(v << 1) + 2];
  }
}
int SegmentTree::get() { return t[0].get(); }
const int N = 200000;
int n, m, k, a[2 * N];
int main() {
  scanf("%d%d%d", &n, &k, &m);
  SegmentTree t(2 * n);
  t.build(0, 0, 2 * n, 0);
  std::set<std::pair<int, int> > s;
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int pos = y - 1 + abs(x - k);
    if (s.count(std::make_pair(x, y))) {
      s.erase(std::make_pair(x, y));
      --a[pos];
      t.update(0, 0, 2 * n, pos, a[pos]);
    } else {
      s.insert(std::make_pair(x, y));
      ++a[pos];
      t.update(0, 0, 2 * n, pos, a[pos]);
    }
    printf("%d\n", std::max(0, n + t.get()));
  }
  return 0;
}