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;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001;
const long long identity = 0;
const long long SZ = 400002;
long long sum[4 * SZ], lazy[4 * SZ];
long long combine(long long A, long long B) { return max(A, B); }
long long combineUpd(long long A, long long B) { return A + B; }
void push(int index, long long L, long long R) {
  sum[index] = combineUpd(sum[index], lazy[index]);
  if (L != R)
    lazy[2 * index] = combineUpd(lazy[2 * index], lazy[index]),
             lazy[2 * index + 1] = combineUpd(lazy[2 * index + 1], lazy[index]);
  lazy[index] = identity;
}
void pull(int index) {
  sum[index] = combine(sum[2 * index], sum[2 * index + 1]);
}
long long query(int lo, int hi, int index = 1, long long L = 1,
                long long R = SZ - 1) {
  push(index, L, R);
  if (lo > R || L > hi) return 0;
  if (lo <= L && R <= hi) return sum[index];
  int M = (L + R) / 2;
  return combine(query(lo, hi, 2 * index, L, M),
                 query(lo, hi, 2 * index + 1, M + 1, R));
}
void update(int lo, int hi, long long increase, int index = 1, long long L = 1,
            long long R = SZ - 1) {
  push(index, L, R);
  if (hi < L || R < lo) return;
  if (lo <= L && R <= hi) {
    lazy[index] = increase;
    push(index, L, R);
    return;
  }
  int M = (L + R) / 2;
  update(lo, hi, increase, 2 * index, L, M);
  update(lo, hi, increase, 2 * index + 1, M + 1, R);
  pull(index);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N, K, M;
  cin >> N >> K >> M;
  for (int i = 0; i < (2 * SZ); i++) sum[i] = 0, lazy[i] = 0;
  for (int i = 0; i < (2 * SZ); i++) {
    update(i, i, i);
  }
  set<pair<int, int> > S;
  priority_queue<pair<int, pair<int, int> > > q;
  for (int i = 0; i < (M); i++) {
    int A, B;
    cin >> A >> B;
    int cur = B + abs(K - A);
    if (S.count({A, B})) {
      S.erase({A, B});
      update(1, cur, -1);
    } else {
      S.insert({A, B});
      update(1, cur, 1);
      q.push({cur, {A, B}});
    }
    while (!q.empty() && !S.count(q.top().second)) {
      q.pop();
    }
    if (q.empty()) {
      cout << 0 << nl;
    } else {
      cout << max(query(1, q.top().first) - N - 1, 0ll) << nl;
    }
  }
  return 0;
}