Bingo!

Time limit1sMemory limit128 MB

Summary
Given a set of balls, decide whether every value from 0 to N appears as the absolute difference of some ordered pair of balls in the set.
Level

Easy3 of 10

Topics
Brute force, Math, Implementation, Array
Solved
No attempts yet

Problem

Albert, Charles and Mary invented a new version of the classic game of Bingo. In traditional Bingo the game is run by a non-player called the caller. At the start each player receives a card holding a unique combination of numbers from 00 to NN arranged in rows and columns. The caller has a bag containing N+1N + 1 balls numbered from 00 to NN. On each turn the caller randomly draws one ball from the bag, announces its number to the players, and sets it aside so it cannot be drawn again. Each player looks for the announced number on the card and marks it if present. The first player to mark a complete pre-announced pattern (for example, a full horizontal line) wins a prize.

In the Albert-Charles-Mary version, on each turn the caller draws a first ball, returns it to the bag, draws a second ball, returns it to the bag, and then calls out the absolute difference between the two ball numbers. To add excitement, before the game starts a possibly empty subset of balls is removed from the bag, leaving at least two balls inside. They want to know whether, using only the balls left in the bag and this new drawing method, every number from 00 to NN can still be called out.

Input

The input consists of several test cases. Each test case is given on exactly two lines. The first line contains two integers NN and BB: NN is as described above (1≤N≤901 \le N \le 90), and BB is the number of balls left in the bag (2≤B≤N+12 \le B \le N + 1). The second line contains BB distinct integers bib_i, the balls left in the bag (0≤bi≤N0 \le b_i \le N).

The last test case is followed by a line containing two zeros.

Output

For each test case, output a single line containing the uppercase letter Y if every number from 00 to NN inclusive can be called out, or the uppercase letter N otherwise.

Examples1

  1. Example 1

    Input
    6 7
    2 1 3 4 0 6 5
    5 4
    5 3 0 1
    5 3
    1 5 0
    0 0
    
    Expected output
    Y
    Y
    N