URI Online Judge | 2855

Lucky Numbers

By Felipe C. Ochial, URI BR Brazil

Timelimit: 1

A lucky number is a number in a given sequence that survives the following exclusion process: Initially every second element is deleted. After that, every third element is deleted and so on until the number in question is in a lower position than the next index to be deleted.

For example, in the sequence [1,2,3,4,5,6,7,8,9,10,11,12,13 ...] we would like to know if the numbers 7 and 9 are lucky. After the first pass we will have [1,3,5,7,9,11,13 ...], after the second pass we will have [1,3,7,9,13 ...]. After the fourth pass [1,3,7,13...]. Thus we can conclude that the number 7 is lucky and that the number 9 is an unlucky number in this sequence.

Alfredo enjoyed the game but is tired of erasing and rewriting each sequence to find out what the lucky numbers are. Can you write a program to determine if given number in a sequence is a lucky number?

Input

The input is composed by several test cases. Each test case is composed by an integer N(0<N<305000) that determines how many numbers there are in the sequence. After this follows N integers Ni(0<Ni<305000) in ascending order. Finally, an integer M(0<M<305000) which represents the sequence digit to be tested.

Output

Print "N" if the tested number is not a lucky number and "Y" otherwise. Break a line after each test case.

Exemplos de Entrada Exemplos de SaĆ­da

10

1 2 3 4 5 6 7 8 9 10

7

10

1 2 3 4 5 6 7 8 9 10

9

25

1 3 8 9 11 12 13 14 15 26 29 38 44 49 50 55 56 57 58 66 77 88 99 105 123

58

Y

N

Y