Air Cownditioning II

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

With the hottest recorded summer ever at Farmer John's farm, he needs a way to cool down his cows. Thus, he decides to invest in some air conditioners.

Farmer John's NN cows (1N201 \leq N \leq 20) live in a barn that contains a sequence of stalls in a row, numbered 11001 \ldots 100. Cow ii occupies a range of these stalls, starting from stall s_is\_i and ending with stall t_it\_i. The ranges of stalls occupied by different cows are all disjoint from each-other. Cows have different cooling requirements. Cow ii must be cooled by an amount c_ic\_i, meaning every stall occupied by cow ii must have its temperature reduced by at least c_ic\_i units.

The barn contains MM air conditioners, labeled 1M1 \ldots M (1M101 \leq M \leq 10). The iith air conditioner costs m_im\_i units of money to operate (1m_i10001 \leq m\_i \leq 1000) and cools the range of stalls starting from stall a_ia\_i and ending with stall b_ib\_i. If running, the iith air conditioner reduces the temperature of all the stalls in this range by p_ip\_i (1p_i1061 \leq p\_i \leq 10^6). Ranges of stalls covered by air conditioners may potentially overlap.

Running a farm is no easy business, so FJ has a tight budget. Please determine the minimum amount of money he needs to spend to keep all of his cows comfortable. It is guaranteed that if FJ uses all of his conditioners, then all cows will be comfortable.

입력

The first line of input contains NN and MM.

The next NN lines describe cows. The iith of these lines contains s_is\_i, t_it\_i, and c_ic\_i.

The next MM lines describe air conditioners. The iith of these lines contains a_ia\_i, b_ib\_i, p_ip\_i, and m_im\_i.

For every input other than the sample, you can assume that M=10M = 10.

출력

Output a single integer telling the minimum amount of money FJ needs to spend to operate enough air conditioners to satisfy all his cows (with the conditions listed above).

힌트

One possible solution that results in the least amount of money spent is to select those that cool the intervals \[2,9]\[2, 9], \[1,2]\[1, 2], and \[6,9]\[6, 9], for a cost of 3+2+5=103 + 2 + 5 = 10.