CF1989A.Catch the Coin

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Catch the Coin

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)(0, 0).

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

In one second, Monocarp can move the character in one of eight directions. If the character is at coordinates (x,y)(x, y), then it can end up at any of the coordinates (x,y+1)(x, y + 1), (x+1,y+1)(x + 1, y + 1), (x+1,y)(x + 1, y), (x+1,y1)(x + 1, y - 1), (x,y1)(x, y - 1), (x1,y1)(x - 1, y - 1), (x1,y)(x - 1, y), (x1,y+1)(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 11, that is, they move from (x,y)(x, y) to (x,y1)(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

The first line contains a single integer nn (1n5001 \le n \le 500) — the number of coins.

In the ii-th of the next nn lines, two integers xix_i and yiy_i (50xi,yi50-50 \le x_i, y_i \le 50) are written — the coordinates of the ii-th coin. The coordinates of all coins are different. No coin is located at (0,0)(0, 0).

Output

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

Note

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

Samples

5
24 42
-2 -1
-1 -2
0 -50
15 0
YES
YES
NO
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验