Олимпиадный тренинг

Задача 38386. Chess battles


Задача

Темы:
Ildar and Vanya got tired of constantly playing chess, so they came up with a new chess game.

The game takes place on a chessboard measuring 2n×2m. This field has 2n rows and 2m columns. For convenience, we will denote as (i, j) the cell of the field, which is in the i-th row and j-th column. The cells of this field are painted black and white with a checkerboard coloring. More precisely, cell (i, j) is white if i + j is even and black otherwise.

The game is organized as follows. Ildar cuts out some white cells of the field. After that he invites Vanya to try to solve the following problem: can he place nm chess kings on the uncut white field squares so that no two exposed kings beat each other, that is, they do not stand on the squares of the field adjacent to the side or corner.

Of course, Ildar plans to make the game interesting and put up several combinations of cut cells that are not easy for Vanya. To do this, he asked you for help. In order to understand how best to act before the game, he wants to practice. To do this, he takes an empty field and wants q times to either cut out some white cell, or return some previously cut cell to the field. After each change, he would like to know what the answer to the problem will be for Vanya.  ;

Help Ildar make the game interesting! Write a program that will respond to his requests.

Input data format
The first line contains three integers n, m, q (1 ≤ n, m, q ≤ 200 000) — the number of checkerboard row pairs, the number of checkerboard column pairs, and the number of requests. 
The next q lines describe Ildar's requests. Each of these lines contains two integers i, j (1 ≤ i ≤ 2n, 1 ≤ j ≤ 2m, i+j is even). If the cell (i, j) is not cut out, then Ildar cuts it out, otherwise he returns it back to the field.

Output data format
Print q lines. In the i-th of these lines print the answer to the problem for the board received after i Ildar's first requests.
Output "YES" (without quotes) if Vanya can place the chess kings on the uncut white squares of the field in such a way that no two kings will beat each other. Otherwise, output "NO" (without quotes).
 
Examples
# Input Output
1 1 3 3
1 1
15
24
YES
YES
NO
2 3 2 10
4 2
6 4
1 3
4 2
6 4
2 2
24
1 3
4 4
3 1
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO

Remark
In the first example, cells (1, 1) and (1, 5) will be cut after the second request. Then Vanya can place three kings on squares (2, 2), (2, 4) and (2, 6).
After the third request, cells (1, 1), (1, 5) and (2, 4) will be cut out. Then there are only three empty cells (2, 2), (1, 3) and (2, 6). Vanya cannot put three kings on these squares, because the kings in the squares (2, 2) and (1, 3) beat each other, since these squares are adjacent in the corner.