It's a beautiful day and you are out at the arcade, and, after examining each game available, you have decided that the most optimal one to play is one named Block Bin, for you believe you have a strategy that can always win (and it has a high reward yield!). It's a pretty simple pixel game where pixels drop down and get cleared after filling the bottom row. The game is detailed as follows:
The screen starts with a grid of rows and
columns. A square in the grid will be referred to as (
,
), where
specifying the column, starting at 1 from the left and incrementing, and
specifying the row, starting at 0 from the bottom and incrementing. (Read again carefully.)
There are blocks in total, each occupying one square of the grid. You will be given
.
You will be told their starting square at the beginning of time 0, each in the form ,
.
Time in this game moves in discrete intervals, moving from time to time
abides by two simple rules:
- If the entire bottom row is filled with blocks, then all blocks in the bottom row are cleared.
- For each remaining block, in order from bottom to top, perform the following:
- If the block is in the bottom row, or if there is a block in the cell immediately below it, do nothing.
- Otherwise, move the block one cell downward.
Remember, the rules are always executed in that order!
The game will then turn the grid display off and then display queries, asking whether the -th block exists after time
but before
.
You will be given , the number of queries.
You must answer this query with a simple "No", if the block hasn't been cleared, or "Yes" if it has. If the block never gets cleared at any point in time, answer instead with "Never".
These will be in the form , where
refers to the
-th block (1-indexed) given to you, and
is the time being queried.
Input
- The first line contains two integers
and
, the number of blocks and the number of columns.
- The next
lines will contain two integers,
, specifying the position of the
-th block.
- The following line contains integer
, the number of queries.
- The next
lines will contain two integers,
, specifying that the
-th block is being queried at time
.
Output
- Either "Yes", "No", or "Never", one for each
queries given.
Constraints
- Two blocks cannot occupy the same square at any time
Example 1
Input
5 3
1 1
1 2
2 2
3 2
2 3
6
1 1
1 2
2 3
2 5
3 4
3 5
Output
No
Never
Yes
Never
Yes
Never
Example 2
Input
3 2
1 1
2 1
1 2
4
1 1
1 2
1 3
2 3
Output
Yes
Yes
Never
Never
Comments