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 N_MAX = 200002;
const int M_MAX = 200002;
const int INF = 1000000;
struct Point {
  int x, y;
};
bool operator<(const Point &a, const Point &b) {
  return make_pair(a.x, a.y) < make_pair(b.x, b.y);
}
int n, m, k;
set<Point> s;
long long f(Point p) { return abs(p.x - k) + p.y; }
struct Update {
  Point p;
  bool type;
  int index;
  int normPos;
};
bool operator<(const Update &a, const Update &b) { return a.index < b.index; }
bool cmpVal(const Update &a, const Update &b) {
  return make_pair(f(a.p), a.p) < make_pair(f(b.p), b.p);
}
Update updates[M_MAX];
struct SGTNode {
  long long maxVal;
  long long lazy;
};
SGTNode SGT[M_MAX * 4];
void SGTSplit(int node) {
  int lSon = (node << 1), rSon = (lSon | 1);
  SGT[lSon].maxVal += SGT[node].lazy;
  SGT[rSon].maxVal += SGT[node].lazy;
  SGT[lSon].lazy += SGT[node].lazy;
  SGT[rSon].lazy += SGT[node].lazy;
  SGT[node].lazy = 0;
}
void SGTUpdateAdd(int node, int l, int r, int ul, int ur, long long uval) {
  if (ul <= l && r <= ur) {
    SGT[node].maxVal += uval;
    SGT[node].lazy += uval;
    return;
  }
  SGTSplit(node);
  int mid = ((l + r) >> 1), lSon = (node << 1), rSon = (lSon | 1);
  if (ul <= mid) SGTUpdateAdd(lSon, l, mid, ul, ur, uval);
  if (mid + 1 <= ur) SGTUpdateAdd(rSon, mid + 1, r, ul, ur, uval);
  SGT[node].maxVal = max(SGT[lSon].maxVal, SGT[rSon].maxVal);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> m;
  for (int i = 1; i <= m; i++) {
    Point p;
    cin >> p.x >> p.y;
    if (s.find(p) != s.end()) {
      updates[i] = Update{p, 0, i, 0};
      s.erase(p);
    } else {
      updates[i] = Update{p, 1, i, 0};
      s.insert(p);
    }
  }
  sort(updates + 1, updates + m + 1, cmpVal);
  for (int i = 1; i <= m; i++)
    updates[i].normPos =
        updates[i - 1].normPos + (i == 1 || cmpVal(updates[i - 1], updates[i]));
  sort(updates + 1, updates + m + 1);
  for (int i = 1; i <= 4 * m; i++) {
    SGT[i].maxVal = -INF - 1;
    SGT[i].lazy = 0;
  }
  int k = 0;
  for (int i = 1; i <= m; i++) {
    if (updates[i].type == 1) {
      SGTUpdateAdd(1, 1, m, updates[i].normPos, updates[i].normPos,
                   INF + f(updates[i].p));
      if (updates[i].normPos < m)
        SGTUpdateAdd(1, 1, m, updates[i].normPos + 1, m, -1);
      k++;
    } else {
      SGTUpdateAdd(1, 1, m, updates[i].normPos, updates[i].normPos,
                   -(INF + f(updates[i].p)));
      if (updates[i].normPos < m)
        SGTUpdateAdd(1, 1, m, updates[i].normPos + 1, m, +1);
      k--;
    }
    cout << max(0LL, SGT[1].maxVal + k - n) << "\n";
  }
  return 0;
}