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>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
int MOD = 1e9 + 7;
void ADD(long long &x, long long v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int SIZE = 1 << 21;
int ma[SIZE], num[SIZE], overhead[SIZE];
void ins(int L, int R, int id, int p, int v) {
  if (L == R) {
    num[id] += v;
    ma[id] = num[id] ? L : 0;
    overhead[id] = max(0, num[id] - 1);
    return;
  }
  int mm = (L + R) / 2;
  if (p <= mm) {
    ins(L, mm, id * 2, p, v);
  } else {
    ins(mm + 1, R, id * 2 + 1, p, v);
  }
  num[id] = num[id * 2] + num[id * 2 + 1];
  ma[id] = max({ma[id * 2], ma[id * 2 + 1]});
  if (overhead[id * 2] + num[id * 2 + 1])
    ma[id] = max(ma[id], overhead[id * 2] + num[id * 2 + 1] + mm);
  overhead[id] =
      max(overhead[id * 2 + 1], overhead[id * 2] + num[id * 2 + 1] - (R - mm));
}
void solve() {
  int n, k, m;
  R(n, k, m);
  set<pair<int, int> > AA;
  for (int i = 0; i < (m); ++i) {
    pair<int, int> x;
    R(x.first, x.second);
    int v = x.second + abs(x.first - k);
    if (AA.count(x)) {
      AA.erase(x);
      ins(1, 1 << 20, 1, v, -1);
    } else {
      AA.insert(x);
      ins(1, 1 << 20, 1, v, 1);
    }
    W(max(0, ma[1] - n));
  }
}
int main() {
  solve();
  return 0;
}