Ingenious Metro

No attempts yetTime limit1sMemory limit128 MB

Problem

The Kingdom of Logonia is about to open a revolutionary new metro line, built on an invention of the Royal Engineers that enables teleportation.

The metro is a very long tunnel with a station every kilometer, so each station sits at an integer position on a number line. Among the stations, $T$ of them contain a teleporter. Every station has a keyboard with $T$ keys, one per teleporter.

The metro works like this: a passenger stands at some station (the start station) and presses the key of the teleporter they want to use. They are then moved to the station that lies at the same distance from that teleporter as the start station, but on the opposite side of it. Formally, if the start station is at position $i$ and the passenger presses the key of the teleporter located at position $j$, they arrive at position $2 \times j - i$.

For example, with teleporters $A$, $B$, and $C$, a passenger at station $6$ who wants to reach station $-2$ could first use teleporter $C$ (moving from $6$ to $10$) and then teleporter $A$ (moving from $10$ to $-2$).

It may happen that no sequence of teleporters can take a passenger from a given station $X$ to a given station $Y$. To stop passengers from trying to reach places they cannot, the King wants a program that, given the position of every teleporter, answers a series of queries. Each query gives a start station and a destination station, and the program must decide whether the passenger can travel from the start to the destination.

Input

The input consists of several test cases.

Each test case begins with a line containing two integers $T$ and $Q$: the number of teleporters ($1 \le T \le 10^5$) and the number of queries ($1 \le Q \le 10$). The next line contains $T$ distinct integers $t_i$, the positions of the teleporters ($-10^7 \le t_i \le 10^7$). Each of the following $Q$ lines describes one query with two distinct integers $S$ and $D$, the positions of the start and destination stations ($-10^7 \le S, D \le 10^7$).

The input ends with a line containing two zeros, which must not be processed.

Output

For each test case, print a single line with the answers to its $Q$ queries, in the order the queries are given. For each query print the uppercase letter $Y$ if the passenger can reach the destination from the start using the metro, or the uppercase letter $N$ otherwise. Separate the answers on a line with single spaces.