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 MAXN = 500100, MAXK = 20;
const long long MOD = 1e9 + 7;
const long long INF = 1e16;
const long double PI = asin(1) * 2;
void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
}
void setIO(string second) {
  setIO();
  freopen((second + ".in").c_str(), "r", stdin);
  freopen((second + ".out").c_str(), "w", stdout);
}
int n, k, m;
int tree[4 * MAXN], lazy[4 * MAXN];
void shift(int id) {
  tree[2 * id] += lazy[id];
  tree[2 * id + 1] += lazy[id];
  lazy[2 * id] += lazy[id];
  lazy[2 * id + 1] += lazy[id];
  lazy[id] = 0;
}
void upd(int x, int y, int d, int id = 1, int le = 1, int ri = n) {
  if (x > ri || y < le) return;
  if (x <= le && ri <= y) {
    tree[id] += d;
    lazy[id] += d;
    return;
  }
  if (le < ri) shift(id);
  int mid = (le + ri) / 2;
  upd(x, y, d, 2 * id, le, mid);
  upd(x, y, d, 2 * id + 1, mid + 1, ri);
  tree[id] = max(tree[2 * id], tree[2 * id + 1]);
}
int get(int x, int y, int id = 1, int le = 1, int ri = n) {
  if (x > ri || y < le) return 0;
  if (x <= le && ri <= y) return tree[id];
  if (le < ri) shift(id);
  int mid = (le + ri) / 2;
  return max(get(x, y, 2 * id, le, mid), get(x, y, 2 * id + 1, mid + 1, ri));
}
set<pair<int, int> > cur;
map<int, int> cnt;
set<int> pos;
int getAns() {
  if ((int)pos.size() == 0) return 0;
  int bg = (*(pos.rbegin()));
  int ans = get(1, bg);
  ans = max(0, ans - n / 2);
  return ans;
}
int main() {
  setIO();
  cin >> n >> k >> m;
  n *= 2;
  for (int i = (1); i <= (n); i++) upd(i, i, i - 1);
  for (int O = (1); O <= ((m)); O++) {
    int x, y;
    cin >> x >> y;
    int nY = y + abs(k - x);
    if (cur.count({x, y})) {
      upd(1, nY, -1);
      cnt[nY]--;
      if (cnt[nY] == 0) pos.erase(nY);
      cur.erase({x, y});
    } else {
      upd(1, nY, 1);
      cnt[nY]++;
      pos.insert(nY);
      cur.insert({x, y});
    }
    cout << getAns() << "\n";
  }
  return 0;
}