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;
enum seg_type { seg_not_lazy, seg_lazy, seg_beats };
template <class node, seg_type type>
struct segment_tree {
  using node_container = typename node::node_container;
  using lazy_container = typename node::lazy_container;

 private:
  template <const bool T = (type != seg_not_lazy),
            typename enable_if<T, bool>::type = 0>
  inline void push(int x, int b, int e, int m) {
    if (st[x].lazy()) {
      st[x + 1].apply(b, m, st[x].lazy);
      st[x + ((m - b) << 1)].apply(m, e, st[x].lazy);
      st[x].lazy = lazy_container();
    }
  }
  template <const bool T = (type != seg_not_lazy),
            typename enable_if<!T, bool>::type = 0>
  inline void push(int x, int b, int e, int m) {}
  template <typename RAIter>
  void build(int x, int b, int e, const RAIter &a) {
    if (b + 1 == e) {
      st[x].nod.build(a[b]);
      return;
    }
    int m = (b + e) >> 1;
    int y = x + ((m - b) << 1);
    build(x + 1, b, m, a);
    build(y, m, e, a);
    st[x].nod = st[x + 1].nod + st[y].nod;
  }
  template <const bool T = (type == seg_beats),
            typename enable_if<!T, bool>::type = 0>
  void update_(int x, int b, int e) {
    if (lo <= b && e <= hi) {
      st[x].apply(b, e, lazy);
      return;
    }
    int m = (b + e) >> 1;
    int y = x + ((m - b) << 1);
    push(x, b, e, m);
    if (lo < m) update_(x + 1, b, m);
    if (m < hi) update_(y, m, e);
    st[x].nod = st[x + 1].nod + st[y].nod;
  }
  template <const bool T = (type == seg_beats),
            typename enable_if<T, bool>::type = 0>
  void update_(int x, int b, int e) {
    if (st[x].break_condition(lazy)) return;
    if (lo <= b && e <= hi && st[x].tag_condition(lazy)) {
      st[x].apply(b, e, lazy);
      return;
    }
    int m = (b + e) >> 1;
    int y = x + ((m - b) << 1);
    push(x, b, e, m);
    if (lo < m) update_(x + 1, b, m);
    if (m < hi) update_(y, m, e);
    st[x].nod = st[x + 1].nod + st[y].nod;
  }
  node_container query(int x, int b, int e) {
    if (lo <= b && e <= hi) return st[x].nod;
    int m = (b + e) >> 1;
    int y = x + ((m - b) << 1);
    push(x, b, e, m);
    if (m >= hi) return query(x + 1, b, m);
    if (m <= lo) return query(y, m, e);
    return query(x + 1, b, m) + query(y, m, e);
  }
  template <class P>
  int find_first(int x, int b, int e, const P &f) {
    if (b + 1 == e) return f(st[x]) ? b : -1;
    int m = (b + e) >> 1;
    int y = x + ((m - b) << 1);
    push(x, b, e, m);
    if (lo < m && f(st[x + 1])) {
      auto t = find_first(x + 1, b, m, f);
      if (t != -1) return t;
    }
    if (m < hi && f(st[y])) return find_first(y, m, e, f);
    return -1;
  }
  template <class P>
  int find_last(int x, int b, int e, const P &f) {
    if (b + 1 == e) return f(st[x]) ? b : -1;
    int m = (b + e) >> 1;
    int y = x + ((m - b) << 1);
    push(x, b, e, m);
    if (m < hi && f(st[y])) {
      auto t = find_last(y, m, e, f);
      if (t != -1) return t;
    }
    if (lo < m && f(st[x + 1])) return find_last(x + 1, b, m, f);
    return -1;
  }
  lazy_container lazy;
  int n, lo, hi;
  vector<node> st;

 public:
  template <typename RAIter>
  void build(const RAIter &a) {
    build(0, 0, n, a);
  }
  void update(int l, int r, const lazy_container &x) {
    lo = l, hi = r, lazy = x, update_(0, 0, n);
  }
  node_container query(int l, int r) { return lo = l, hi = r, query(0, 0, n); }
  template <class P>
  int find_first(int l, int r, const P &f) {
    return lo = l, hi = r, find_first(0, 0, n, f);
  }
  template <class P>
  int find_last(int l, int r, const P &f) {
    return lo = l, hi = r, find_last(0, 0, n, f);
  }
  segment_tree(int n) : n(n), st(2 * n - 1) {}
};
struct node {
  struct node_container {
    int x;
    template <typename T>
    inline void build(const T &a) {
      x = a;
    }
    friend node_container operator+(node_container l, const node_container &r) {
      l.x = max(l.x, r.x);
      return l;
    }
    node_container() : x(0) {}
  } nod;
  struct lazy_container {
    int add;
    inline bool operator()() { return add != 0; }
    lazy_container(int add = 0) : add(add) {}
  } lazy;
  inline void apply(int l, int r, lazy_container &p) {
    nod.x += p.add;
    lazy.add += p.add;
  }
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  const int N = 1e6;
  vector<int> a(N + 1);
  for (int i = 0; i <= N; ++i) a[i] = -(N - i);
  segment_tree<node, seg_lazy> st(N + 1);
  st.build(a.begin());
  multiset<int> z;
  z.insert(n);
  set<pair<int, int>> s;
  for (int x, y; m--;) {
    cin >> x >> y;
    int sg = +1;
    if (s.find({x, y}) != s.end()) {
      s.erase({x, y});
      sg = -1;
    } else
      s.insert({x, y});
    y += abs(k - x);
    if (sg > 0)
      z.insert(y);
    else
      z.erase(z.find(y));
    st.update(0, y + 1, sg);
    int l = *z.rbegin(), r = N - 10;
    while (l < r) {
      int md = (l + r) >> 1;
      if (st.query(0, md + 1).x - a[md + 1] <= 0)
        r = md;
      else
        l = md + 1;
    }
    cout << l - n << "\n";
  }
  return 0;
}