Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

2219.   A famous math puzzle
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 501   Accepted Runs: 245



Maybe you knew this famous puzzle when you were a child.

You have two jugs, A and B, and an infinite supply of water. There are three types of actions that you can use: (1) you can fill a jug, (2) you can empty a jug, and (3) you can pour from one jug to the other. Pouring from one jug to the other stops when the first jug is empty or the second jug is full, whichever comes first.

For example, if A has 5 gallons and B has 6 gallons and a capacity of 8, then pouring from A to B leaves B full and 3 gallons in A. As to a given cubage W, a solution is a sequence of steps that leaves exactly W gallons in one of the jugs.

For example, when A=5, B=6 and W=4, we can take the following steps to achieve the goal.

 AB
initial00
fill A50
pour A B05
fill A55
pour A B46
empty B40

Today, we will generalize the puzzle. You are given N jugs, and asked to decide whether a goal W can be achieved.

Input

Input to your program consists of multiple test cases. Every test case starts with a line consists of two integers N and W. Then N lines follow, each line consisits of a single positive integer that is the capacity of the ith jug (1 ≤ N ≤ 100).

Input is terminated with N=0 and W=0.

Output

For each test case, if the goal can be achieved, you should output YES in a single line. Otherwise output NO in a single line.

Sample Input

2 4
5
6
2 10
65
39
2 12
4
8
3 9
10
35
14
0 0

Sample Output

YES
NO
NO
YES



Source: TOJ 2006 Weekly Contest 5
Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.2.4