atcoder#AGC051F. [AGC051F] rng_58's Last Problem

[AGC051F] rng_58's Last Problem

Score : 24002400 points

Problem Statement

You have two sandglasses: a sandglass that can measure 11 second, and a sandglass that can measure 2\sqrt{2} seconds. Is it possible to measure x+y2x + y \sqrt{2} seconds using them?

Let's formalize the statement. We have two sandglasses named AA and BB. Each sandglass has two bulbs, and the bulbs may contain sand. We can place each sandglass in one of the three states: two vertical states (one of the bulbs is placed on top of the other, and in case the top bulb contains sand, the sand in the top bulb keeps falling into the bottom bulb at the speed of one gram per second.) and one horizontal state (the sand does not move.)

The sandglass A contains 11 gram of sand and the sandglass B contains 2\sqrt{2} grams of sand. Thus, when sandglass AA is vertically placed and all sand is in the top bulb, it takes 11 second until all sand falls into the bottom bulb. Similarly, this time is 2\sqrt{2} seconds for sandglass BB.

Initially, both AA and BB are vertically placed, and all sand is in the bottom bulb. You are not allowed to touch anything before Snuke shouts. When an event (described below) happens exactly tt seconds after Snuke shouts, we say that we can measure tt seconds.

We say that an event happens when one of the following happens:

  • Snuke shouts.
  • The sand in a sandglass in a vertical state has just stopped falling down.

When an event happens, we can perform (an arbitrary number of) the following operation in negligible time:

  • Choose a sandglasses, and change its state.

For example, we can measure 1+22-1 + 2 \sqrt{2} seconds as follows:

  • At time 00, Snuke shouts. Turn both AA and BB upside down.
  • At time 11, an event happens: the sand in AA stops falling down. Turn AA upside down again (and leave BB as it is).
  • At time 2\sqrt{2}, an event happens: the sand in BB stops falling down. Turn AA upside down again, and leave BB in the horizontal state.
  • At time 1+22-1 + 2 \sqrt{2}, an event happens: the sand in AA stops falling down.

You are given QQ numbers of the form xi+yi2x_i + y_i \sqrt{2}. Solve the problem above for each given number.

Constraints

  • 1Q1051 \leq Q \leq 10^5
  • 109xi,yi109-10^9 \leq x_i, y_i \leq 10^9
  • xi+yi2>0x_i + y_i \sqrt{2} > 0
  • All values in the input are integers.

Input

Input is given from Standard Input in the following format:

QQ

x1x_1 y1y_1

::

xQx_Q yQy_Q

Output

Print QQ lines. On the ii-th line, print Yes if it is possible to measure xi+yi2x_i + y_i \sqrt{2} seconds; otherwise print No.

3
-1 2
2020 1227
2 -1
Yes
Yes
No