cho.sh
Notes
Loading...

Points

Time limit

1s

Memory limit

128 MB

Problem

Let S be a set of points with natural-number coordinates on the coordinate plane. Initially, S contains exactly one point (a, b). You may repeatedly apply any of the following rules, in any order, and add the newly created point to S.

  • Rule 1: If (x, y) is in S, add (x + 1, y + 1) to S.
  • Rule 2: If (x, y) is in S and both x and y are even, add (x / 2, y / 2) to S.
  • Rule 3: If both (x, y) and (y, z) are in S, add (x, z) to S.

Given the initial point (a, b), determine for each queried point (p, q) whether it can be added to S by repeatedly applying these rules.

Input

The first line contains two natural numbers a and b, the coordinates of the point initially in S.

Each of the next five lines contains two natural numbers p and q, the coordinates of one queried point.

All coordinates in the input are between 1 and 100,000, inclusive.

Output

For the five queried points, output whether each point can be created by repeatedly applying the three rules.

For each query, print Y if it can be created, and N otherwise, one answer per line in input order.