Some things grow if you put them together. We have some metallic bars, theirs length known, and, if necessary, we want to solder some of them in order to obtain another one being exactly a given length long. No bar can be cut up. Is it possible?
The first line of the input contains an integer,t, 0 ≤ t ≤ 50, indicating the number of test cases. For each test case, three lines appear, the first one contains a number n, 0 ≤ n ≤ 1000, representing the length of the bar we want to obtain. The second line contains a number p, 1 ≤ p ≤ 20, representing the number of bars we have. The third line of each test case contains p numbers, representing the length of the p bars.
For each test case the output should contain a single line, consists of the string ‘YES’ or the string ‘NO’, depending on whether solution is possible or not.
範例輸入 1
4 25 4 10 12 5 7 925 10 45 15 120 500 235 58 6 12 175 70 120 5 25 25 25 25 25 0 2 13 567
範例輸出 1
NO YES NO YES
Pro 專屬功能: 查看這題在歷屆 CPE 出現過幾次 — 升級以解鎖.