Jam's balance

Time Limit: 1000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 5616
64-bit integer IO format: %I64d      Java class name: Main

Description

Jim has a balance and N weights. $(1 \leq N \leq 20)$
The balance can only tell whether things on different side are the same weight.
Weights can be put on left side or right side arbitrarily.
Please tell whether the balance can measure an object of weight M.

Input

The first line is a integer $T(1 \leq T \leq 5)$, means T test cases.
For each test case :
The first line is $N$, means the number of weights.
The second line are $N$ number, i'th number $w_i (1 \leq w_i \leq 100)$ means the i'th weight's weight is $w_i$.
The third line is a number $M$. $M$ is the weight of the object being measured.

Output

You should output the "YES"or"NO".

Sample Input

1
2
1 4
3
2
4
5

Sample Output

NO
YES
YES

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .