Voter Depression

Pick non-overlapping story intervals to multiply exposed voters' propensities and maximize the right-minus-left propensity gap.

Medium5Dynamic programmingIntervalsSortingNo attempts yetTime limit2sMemory limit512 MB

Problem

In an election, fake news is used to keep the other candidate's supporters at home rather than to raise turnout for your own side. The usual method targets a specific group with negative messages about the candidate that group supports, shaped to fit biases the group already holds. This problem models that situation as follows.

Voter jj sits at a real position xjx_j on an axis that runs from the political left to the political right, and no voter sits at 0. A voter with xj<0x_j < 0 votes for the left candidate, and a voter with xj>0x_j > 0 votes for the right candidate. Voter jj has propensity pjp_j to vote.

Fake news story ii is given by an interval [i,ri][\ell_i, r_i] and a factor did_i with 0di10 \le d_i \le 1. When a voter inside [i,ri][\ell_i, r_i] is exposed to that story, the propensity of that voter changes from pjp_j to pj×dip_j \times d_i.

The campaign selects a set of stories to deploy so that no voter falls inside two or more of the selected intervals. A voter inside one selected interval is exposed to that story. After all selected stories are deployed, maximize the total propensity of the voters who vote for the right candidate minus the total propensity of the voters who vote for the left candidate.

Input

The first line contains the number of data sets KK (1K1001 \le K \le 100). The KK data sets follow in order.

The first line of a data set contains the number of voters nn and the number of fake news stories mm (1n2001 \le n \le 200, 1m501 \le m \le 50).

Each of the next nn lines contains the position xjx_j and the propensity pjp_j of voter jj (1xj1-1 \le x_j \le 1, xj0x_j \ne 0, 0pj10 \le p_j \le 1). The voters are given in non-decreasing order of xjx_j.

Each of the next mm lines contains i\ell_i, rir_i and did_i of story ii (1iri1-1 \le \ell_i \le r_i \le 1, 0di10 \le d_i \le 1). The stories are given in non-decreasing order of rir_i.

Every number is given with at most two digits after the decimal point. No xjx_j equals any i\ell_i or any rir_i.

Output

For each data set, first print Data Set x: on a line of its own, where xx is the number of the data set counting from 1.

On the next line print the largest achievable value of the total propensity of the voters for the right candidate minus the total propensity of the voters for the left candidate, rounded to two digits after the decimal point. A value exactly halfway between two outputs rounds away from zero, so 0.375 prints as 0.38 and -0.125 prints as -0.13. Print 0.00 rather than -0.00.

Print a blank line after each data set.