Catch the Coin
Contest: Educational Codeforces Round 167 (Rated for Div. 2)
Difficulty rating: 800
Tags: implementation

Monocarp visited a retro arcade club with arcade cabinets. There got curious about the "Catch the Coin" cabinet.

The game is pretty simple. The screen represents a coordinate grid such that:

- the X-axis is directed from left to right;
- the Y-axis is directed from bottom to top;
- the center of the screen has coordinates $$$(0, 0)$$$.

At the beginning of the game, the character is located in the center, and $$$n$$$ coins appear on the screen — the $$$i$$$-th coin is at coordinates $$$(x_i, y_i)$$$. The coordinates of all coins are different and not equal to $$$(0, 0)$$$.

In one second, Monocarp can move the character in one of eight directions. If the character is at coordinates $$$(x, y)$$$, then it can end up at any of the coordinates $$$(x, y + 1)$$$, $$$(x + 1, y + 1)$$$, $$$(x + 1, y)$$$, $$$(x + 1, y - 1)$$$, $$$(x, y - 1)$$$, $$$(x - 1, y - 1)$$$, $$$(x - 1, y)$$$, $$$(x - 1, y + 1)$$$.

If the character ends up at the coordinates with a coin, then Monocarp collects that coin.

After Monocarp makes a move, all coins fall down by $$$1$$$, that is, they move from $$$(x, y)$$$ to $$$(x, y - 1)$$$. You can assume that the game field is infinite in all directions.

Monocarp wants to collect at least one coin, but cannot decide which coin to go for. Help him determine, for each coin, whether he can collect it.

Input format:
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 500$$$) — the number of coins.

In the $$$i$$$-th of the next $$$n$$$ lines, two integers $$$x_i$$$ and $$$y_i$$$ ($$$-50 \le x_i, y_i \le 50$$$) are written — the coordinates of the $$$i$$$-th coin. The coordinates of all coins are different. No coin is located at $$$(0, 0)$$$.

Output format:
For each coin, print "YES" if Monocarp can collect it. Otherwise, print "NO".

Constraints:
Time limit: 2.0 s
Memory limit: 256.0 MB

Note:
Pay attention to the second coin in the example. Monocarp can first move from $$$(0, 0)$$$ to $$$(-1, -1)$$$. Then the coin falls $$$1$$$ down and ends up at $$$(-2, -2)$$$. Finally, Monocarp moves to $$$(-2, -2)$$$ and collects the coin.

Example input:
5
24 42
-2 -1
-1 -2
0 -50
15 0

Example output:
YES
YES
NO
NO
YES

Editorial:
At first glance, it's not very convenient that the move consists of two parts: first the character moves, then the coin. Let's try to combine these steps. Since the coin moves down by $$$1$$$ each time, we can add this change in the $$$y$$$ coordinate to the change in the character's $$$y$$$ coordinate. That is, the character can now change its $$$y$$$ coordinate not by $$$-1, 0$$$, or $$$1$$$, but by $$$0, 1$$$, or $$$2$$$. And the coins will always be in their initial positions.
Now it is easy to see that all coins with $$$y \ge 0$$$ can be picked up. For example, you can first align with the coin in terms of the $$$x$$$ coordinate, and then move up to it.
However, in the example, it can be seen that Monocarp can pick up the coin $$$(-2, -1)$$$. This happens because the move still consists of two parts. Since the character moves first, and then the coin, we can align with the $$$x$$$ coordinate again, and then have the time to move down to it.
Thus, all coins with $$$y \ge -1$$$ can be picked up.
Overall complexity: $$$O(n)$$$.