This page is still under construction.

Parts of this page are still being built. What you see may change.

Cutting Banknotes

Time limit1sMemory limit1024 MB

Summary
Given a target amount in cents and a set of banknote values, decide whether some subset of notes can be split into halves repeatedly so the resulting pieces sum exactly to the target.
Level

Medium5 of 10

Topics
Math, Number theory, Greedy, Bit manipulation
Solved
No attempts yet

Problem

Philip often faces a big problem: after going out for dinner or having a few beers, he owes money to his friends, or the other way around. These are usually small amounts, but Philip hates coins, so his wallet contains only banknotes. That means he usually cannot pay the amount exactly. Since he hates coins, he also does not allow his friends to give coins as change. He does allow banknotes as change.

To deal with this problem, he and his friends came up with an idea: pay with pieces of banknotes. To make cutting easy, they only cut a banknote into two equally sized pieces, cut those pieces into two pieces each, and so on. This gives a much larger range of amounts that can be paid. Philip wonders which amounts exactly.

Input

The first line contains an integer tt (1 ≤ tt ≤ 100): the number of test cases. Then, for each test case:

  • One line with a number xx (0.01 ≤ xx ≤ 10 000.00): the amount Philip has to pay. It is formatted with two decimal digits and a period as the decimal separator.
  • One line with a positive integer nn (1 ≤ nn ≤ 1 000): the number of different banknotes.
  • nn lines, each with an integer bib_i (1 ≤ bib_i ≤ 10 000): the values of the banknotes.

Output

For each test case:

  • One line with yes if the amount can be paid exactly, and no otherwise.

Examples1

  1. Example 1

    Input
    4
    10.75
    3
    2
    10
    20
    0.33
    1
    1
    10000.00
    1
    2500
    1.00
    2
    3
    5
    
    Expected output
    yes
    no
    yes
    yes