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;
struct node {
  int maxi, add, val, block;
  int size, l, r, fix;
  bool flag;
} v[200000 + 20];
void update(int index) {
  v[index].maxi = v[index].val;
  v[index].size = 1;
  if (v[index].l) {
    v[index].size += v[v[index].l].size;
    v[index].maxi = max(v[index].maxi, v[v[index].l].maxi + v[index].add);
  }
  if (v[index].r) {
    v[index].size += v[v[index].r].size;
    v[index].maxi = max(v[index].maxi, v[v[index].r].maxi + v[index].add);
  }
}
void push_down(int index) {
  if (v[index].flag) {
    if (v[index].l) {
      v[v[index].l].flag ^= 1;
      swap(v[v[index].l].l, v[v[index].l].r);
    }
    if (v[index].r) {
      v[v[index].r].flag ^= 1;
      swap(v[v[index].r].l, v[v[index].r].r);
    }
    v[index].flag = 0;
  }
  if (v[index].l) {
    v[v[index].l].add += v[index].add;
    v[v[index].l].maxi += v[index].add;
    v[v[index].l].val += v[index].add;
  }
  if (v[index].r) {
    v[v[index].r].add += v[index].add;
    v[v[index].r].maxi += v[index].add;
    v[v[index].r].val += v[index].add;
  }
  v[index].add = 0;
}
int cnt = 0;
int getnewnode(int val, int block) {
  node tmp;
  tmp.maxi = val;
  tmp.val = val;
  tmp.add = tmp.flag = 0;
  tmp.size = 1;
  tmp.l = tmp.r = 0;
  tmp.block = block;
  tmp.fix = rand() % 1234567890;
  cnt++;
  v[cnt] = tmp;
  return cnt;
}
void split(int base, int& x, int& y, int boundary) {
  if (!base) {
    x = y = 0;
    return;
  }
  if (v[base].size == boundary) {
    x = base;
    y = 0;
    update(x);
  }
  if (!boundary) {
    x = 0;
    y = base;
    update(y);
  }
  push_down(base);
  if (v[v[base].l].size >= boundary) {
    y = base;
    v[y] = v[base];
    split(v[base].l, x, v[y].l, boundary);
    update(y);
  } else {
    x = base;
    v[x] = v[base];
    split(v[base].r, v[x].r, y, boundary - v[v[base].l].size - 1);
    update(x);
  }
}
void split2(int base, int& x, int& y, int boundary) {
  if (!base) {
    x = y = 0;
    return;
  }
  push_down(base);
  if (v[base].block >= boundary) {
    y = base;
    split2(v[base].l, x, v[y].l, boundary);
    update(y);
  } else {
    x = base;
    split2(v[base].r, v[x].r, y, boundary);
    update(x);
  }
}
int merge(int x, int y) {
  if ((!x) || (!y)) {
    if (x + y) {
      update(x + y);
    }
    return x + y;
  }
  if (v[x].fix > v[y].fix) {
    push_down(x);
    v[x].r = merge(v[x].r, y);
    update(x);
    return x;
  } else {
    push_down(y);
    v[y].l = merge(x, v[y].l);
    update(y);
    return y;
  }
}
int root = 1;
map<pair<int, int>, bool> M;
int main() {
  srand(19260817);
  ios::sync_with_stdio(false);
  int n, k, m;
  cin >> n >> k >> m;
  int cnt = 0;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    int val = y + abs(x - k);
    if (M[make_pair(x, y)]) {
      cnt--;
      if (cnt == 0) {
        cnt = 0;
        M[make_pair(x, y)] = 0;
        cout << 0 << endl;
        continue;
      } else {
        int L, R;
        split2(root, L, R, val);
        int MID;
        split(R, MID, R, 1);
        v[L].add--;
        v[L].val--;
        v[L].maxi--;
        root = merge(L, R);
      }
    } else {
      cnt++;
      if (cnt == 1) {
        root = getnewnode(val, val);
      } else {
        int L, R;
        split2(root, L, R, val);
        if (L) {
          v[L].add++;
          v[L].val++;
          v[L].maxi++;
        }
        int Add = 0;
        if (R) Add += v[R].size;
        int MID = getnewnode(Add + val, val);
        L = merge(L, MID);
        root = merge(L, R);
      }
    }
    cout << max(0, v[root].maxi - n) << endl;
    M[make_pair(x, y)] ^= 1;
  }
  return 0;
}