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>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
using Graph = vector<vector<int>>;
using ll = long long;
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> v) {
  os << "( " << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<set<T>> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &v) {
  int i = 0;
  for (auto it : v) {
    if (i > 0) {
      os << ' ';
    }
    os << it;
    i++;
  }
  return os;
}
using Value = pair<int, int>;
const Value ini = make_pair(-1, -1);
Value connect(Value al, const Value ar) {
  if (ar.first == -1) return al;
  if (al.first == -1) return ar;
  if (al.first + al.second <= ar.first) {
    return make_pair(ar.first - al.second, al.second + ar.second);
  } else {
    return make_pair(al.first, al.second + ar.second);
  }
}
Value dat[4000001];
struct segtree {
  int N;
  segtree() {}
  segtree(int n) {
    N = 1;
    while (N < n) N *= 2;
    for (int x = 0; x < N; ++x) {
      { dat[x + N - 1] = ini; }
    }
    for (int x = N - 2; x >= 0; --x) {
      dat[x] = connect(dat[x * 2 + 1], dat[x * 2 + 2]);
    }
  }
  void update(int k, const Value &a) {
    k += N - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) >> 1;
      dat[k] = connect(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  Value query(int a, int b) { return query(a, b, 0, 0, N); }
  Value query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return ini;
    if (a <= l && r <= b) return dat[k];
    const int m = (l + r) / 2;
    return connect(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  int N, K, M;
  cin >> N >> K >> M;
  set<pair<int, int>> aset;
  segtree seg(1e6);
  vector<int> cnts(1e6);
  for (int i = 0; i < M; ++i) {
    int x, y;
    cin >> x >> y;
    int po_y = y + abs(x - K);
    if (aset.find(make_pair(x, y)) == aset.end()) {
      aset.emplace(make_pair(x, y));
      cnts[po_y]++;
      seg.update(po_y, make_pair(po_y, cnts[po_y]));
    } else {
      aset.erase(make_pair(x, y));
      cnts[po_y]--;
      if (cnts[po_y] == 0) {
        seg.update(po_y, make_pair(-1, -1));
      } else {
        seg.update(po_y, make_pair(po_y, cnts[po_y]));
      }
    }
    auto pp = seg.query(0, int(1e6));
    int needh = pp.first + pp.second - 1;
    cout << max(0, needh - N) << endl;
  }
  return 0;
}