Block Bin


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 101810^{18} rows and ZZ columns. A square in the grid will be referred to as (xx, yy), where xx specifying the column, starting at 1 from the left and incrementing, and yy specifying the row, starting at 0 from the bottom and incrementing. (Read again carefully.)

There are CC blocks in total, each occupying one square of the grid. You will be given CC.

You will be told their starting square at the beginning of time 0, each in the form xix_i, yiy_i.

Time in this game moves in discrete intervals, moving from time aa to time a+1a+1 abides by two simple rules:

  1. If the entire bottom row is filled with blocks, then all blocks in the bottom row are cleared.
  2. 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 ii-th block exists after time tt but before t+1t+1.

You will be given qq, 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 citic_i t_i, where cic_i refers to the ii-th block (1-indexed) given to you, and tit_i is the time being queried.

Input

  • The first line contains two integers CC and ZZ, the number of blocks and the number of columns.
  • The next CC lines will contain two integers, xiyix_i y_i, specifying the position of the ii-th block.
  • The following line contains integer qq, the number of queries.
  • The next qq lines will contain two integers, tiit_i i, specifying that the ii-th block is being queried at time tit_i.

Output

  • Either "Yes", "No", or "Never", one for each qq queries given.

Constraints

  • 1iC2×1051 \leq i \leq C \leq 2 \times 10^5
  • 1ZC1 \leq Z \leq C
  • 1XiZ1 \leq X_i \leq Z
  • 1Yi10181 \leq Y_i \leq 10^{18}
  • 1q1051 \leq q \leq 10^5
  • 1ti10181 \leq t_i \leq 10^{18}
  • Two blocks cannot occupy the same square at any time

Example 1

Input 1
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 1
No
Never
Yes
Never
Yes
Never

Example 2

Input 2
3 2
1 1
2 1
1 2
4
1 1
1 2
1 3
2 3
Output 2
Yes
Yes
Never
Never

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.