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 JAVA):

Solution:
import java.io.*;
import java.util.*;
import java.math.*;

public class G {
    static final boolean RUN_TIMING = false;
    static char[] inputBuffer = new char[1 << 20];
    static PushbackReader in = new PushbackReader(new BufferedReader(new InputStreamReader(System.in)), 1 << 20);
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public void go() throws IOException {
        // in = new PushbackReader(new BufferedReader(new FileReader(new File("test.txt"))), 1 << 20);
        // out = new PrintWriter(new FileWriter(new File("output.txt")));
        int n = ipar();
        int k = ipar();
        int m = ipar();
        HashSet<Long> seen = new HashSet<>();
        SegmentTree tree = new SegmentTree(2*n);
        for (int i = 0; i < m; i++) {
            long x = ipar();
            long y = ipar();
            long p = x*n + y;
            int index = (int)(y + Math.abs(x - k));
            if (seen.contains(p)) {
                seen.remove(p);
                tree.update(index, -1);
            } else {
                seen.add(p);
                tree.update(index, 1);
            }
            out.println(Math.max(tree.query() - n - 1, 0));
        }
    }

    private class SegmentTree {
        private class Node {
            int sum;
            int suffix;
        }

        Node[] tree;
        int n;

        public SegmentTree(int n) {
            tree = new Node[n*4];
            for (int i = 0; i < n*4; i++) {
                tree[i] = new Node();
            }
            this.n = n;
            build(1, 1, n);
        }

        // private Node makeNode(int x) {
        //     Node curr = new Node();
        //     curr.sum = x;
        //     curr.suffix = Math.max(0, x);
        //     return curr;
        // }

        // private Node combine(Node left, Node right) {
        //     Node curr = new Node();
        //     curr.sum = left.sum + right.sum;
        //     curr.suffix = Math.max(right.suffix, right.sum + left.suffix);
        //     return curr;
        // }

        private void updateNode(int v) {
            Node curr = tree[v];
            Node left = tree[v*2];
            Node right = tree[v*2+1];
            curr.sum = left.sum + right.sum;
            curr.suffix = Math.max(right.suffix, right.sum + left.suffix);
        }

        private void build(int v, int tl, int tr) {
            if (tl == tr) {
                tree[v].sum = 0;
                tree[v].suffix = 0;
                return;
            }
            int tm = (tl + tr) / 2;
            build(v*2, tl, tm);
            build(v*2+1, tm+1, tr);
            updateNode(v);
        }

        private void update(int v, int tl, int tr, int i, int x) {
            if (tl == tr) {
                tree[v].sum += x;
                tree[v].suffix = tree[v].sum != 0 ? tl + tree[v].sum : 0;
                return;
            }
            int tm = (tl + tr) / 2;
            if (i <= tm) {
                update(v*2, tl, tm, i, x);
            } else {
                update(v*2+1, tm+1, tr, i, x);
            }
            updateNode(v);
        }

        public void update(int i, int x) {
            update(1, 1, n, i, x);
        }

        public int query() {
            return tree[1].suffix;
        }
    }

    public int ipar() throws IOException {
        return Integer.parseInt(spar());
    }

    public int[] iapar(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar() throws IOException {
        return Long.parseLong(spar());
    }

    public long[] lapar(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar() throws IOException {
        return Double.parseDouble(spar());
    }

    public String spar() throws IOException {
        int len = 0;
        int c;
        do {
            c = in.read();
        } while (Character.isWhitespace(c) && c != -1);
        if (c == -1) {
            throw new NoSuchElementException("Reached EOF");
        }
        do {
            inputBuffer[len] = (char)c;
            len++;
            c = in.read();
        } while (!Character.isWhitespace(c) && c != -1);
        while (c != '\n' && Character.isWhitespace(c) && c != -1) {
            c = in.read();
        }
        if (c != -1 && c != '\n') {
            in.unread(c);
        }
        return new String(inputBuffer, 0, len);
    }

    public String linepar() throws IOException {
        int len = 0;
        int c;
        while ((c = in.read()) != '\n' && c != -1) {
            if (c == '\r') {
                continue;
            }
            inputBuffer[len] = (char)c;
            len++;
        }
        return new String(inputBuffer, 0, len);
    }

    public boolean haspar() throws IOException {
        String line = linepar();
        if (line.isEmpty()) {
            return false;
        }
        in.unread('\n');
        in.unread(line.toCharArray());
        return true;
    }

    public static void main(String[] args) throws IOException {
        long time = 0;
        time -= System.nanoTime();
        new G().go();
        time += System.nanoTime();
        if (RUN_TIMING) {
            System.out.printf("%.3f ms%n", time / 1000000.0);
        }
        out.flush();
        in.close();
    }
}