F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Game Arrangement

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 215    Accepted Submission(s): 57


Problem Description
Luras is fond of playing games. Once she gets free, she might try playing games such as dato and cf.

However, if you have read the past problems, you will know that luras is very busy even if she skips many classes.

As a result, she wants to arrange her time for playing more rounds of games during her free time.

It is known that luras has m types of games which she is willing to play, and for each game type, there is a time segment,

luras will only try playing one game type during its limited time segment (and ofc in the class-skipping time).

Besides, you are told of the needed time for each round of every game type.

Be attention, once luras started a game, she needs to finish it without any break during the limited time.

Now please help luras arrange her time in order to play more rounds of games.
 

Input
The first line is an integer T which indicates the case number.

and as for each case,

the first line are two integer n and m which indicate the number of time segment of skipping the class and the game types luras wants to try.

then there are n lines, for the i-th line, there are 2 integers L[i] and R[i], which mean that luras could skip the class for games at the R[i] - L[i] + 1 time point { L[i], L[i] + 1, ..., R[i] - 1, R[i] }.

then there are m lines, for the i-th line, there are 3 integers l[i], r[i] and d[i], which mean that only during the r[i] - l[i] + 1 time point { l[i], l[i] + 1, ..., r[i] - 1, r[i] }, could luras play the i-th type game.
once luras spends a d[i] continuous time segment during [ l[i], r[i] ], she could finish 1 round of the i-th game.

At last please note luras could only play at most 1 round game at a time point, she is a cut noob : ) .

It is guaranteed that¡ª¡ª

1 <= T <= 1000

1 <= L[1] <= R[1] < L[2] <= R[2] < ... < L[n] <= R[n] <= 10^9

1 <= l[] <= r[] <= 10^9

1 <= d[] <= 10^9

for 99% cases£¬1 <= n, m <= 100

for 100% cases£¬1 <= n, m <= 10000
 

Output
As for each case, you need to output a single line.

there should be 1 integer in the line which represents the most rounds of games luras can play if she arrange in the best way.
 

Sample Input
4 2 2 1 1 2 5 1 3 1 4 5 2 2 2 1 1 3 4 1 3 1 4 5 2 3 1 1 1 3 3 5 5 1 5 2 1 1 1 10 3 5 2
 

Sample Output
4 2 0 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 09:00:22, Gzip enabled