Containers and Reagents

Decide whether all reagents can be fully distributed among containers so each container's volume range and one reagent's minimum percentage are met.

Hard8GreedyMathImplementationBinary searchNo attempts yetTime limit2sMemory limit512 MB

Problem

Peter got a new task from his chemistry teacher. He has to pour reagents into containers. There are nn containers and mm reagents.

Container ii carries two constraints. The total volume of liquid in it must be at least mini\min_i milliliters and at most maxi\max_i milliliters, and reagent cic_i must occupy at least pip_i percent of the liquid volume in it.

Peter has viv_i milliliters of reagent ii. Every reagent must be poured into containers completely, and every container must hold at least one reagent. A poured amount does not have to be an integer. No chemical reaction happens and no volume changes.

Decide whether Peter can pour everything so that all constraints hold.

For example, suppose there are 3 containers and 4 reagents, the container constraints are (min,max,c,p)=(5,8,1,60),(4,6,3,80),(3,4,4,70)(\min, \max, c, p) = (5, 8, 1, 60), (4, 6, 3, 80), (3, 4, 4, 70) in this order, and the available reagent volumes are 3,4,4,33, 4, 4, 3. Pour 3 milliliters of reagent 1 and 2 milliliters of reagent 2 into container 1, 4 milliliters of reagent 3 and 1 milliliter of reagent 2 into container 2, and 3 milliliters of reagent 4 and 1 milliliter of reagent 2 into container 3. The volumes are 5, 5 and 4 milliliters, all inside their ranges, and the percentages are 3/5=60%3/5 = 60\%, 4/5=80%4/5 = 80\% and 3/4=75%70%3/4 = 75\% \ge 70\%. Every reagent is used up, so the answer here is YES.

Input

The input contains several test cases. The first line holds the number of test cases tt (1t1001 \le t \le 100).

The first line of each test case holds the number of containers nn and the number of reagents mm (1n,m1051 \le n, m \le 10^5).

The ii-th of the next nn lines holds four integers mini\min_i, maxi\max_i, cic_i, pip_i (1minimaxi1051 \le \min_i \le \max_i \le 10^5, 1cim1 \le c_i \le m, 1pi1001 \le p_i \le 100): the minimum volume of liquid in container ii, its maximum volume, the number of the reagent that carries the percentage constraint there, and the minimum percentage that reagent must occupy.

The next line holds the integers v1,v2,,vmv_1, v_2, \dots, v_m (1vi1051 \le v_i \le 10^5).

The sum of nn and the sum of mm over all test cases in one input each do not exceed 10510^5.

Output

For each test case print the answer on its own line. Print YES if the reagents can be poured so that all constraints hold, and NO otherwise. Print both words in upper case.