Enemies and Sabers
"'markdown Cossack Vus has arrived at the Sich to visit a friend who has begun forging sabers in his workshop. This friend has already crafted sabers, where the -th saber is characterized by two parameters: length and sharpness, denoted as and respectively. The cost of the -th saber is karbovantsiv.
Recently, enemies have appeared at the Sich. The ataman has offered a reward for capturing each enemy — capturing the -th enemy provides a reward of karbovantsiv. Each enemy has armor with specific parameters: thickness and strength, denoted as and respectively.
To capture an enemy, their armor must be pierced. This requires a saber whose length is at least as great as the armor's thickness, and whose sharpness is at least as great as the armor's strength. Formally, the -th saber can capture the -th enemy if both conditions are satisfied: and .
Cossack Vus wants to determine the maximum number of karbovantsiv he can earn to decide if engaging in this risky venture is worthwhile, and he seeks your assistance.
Note that at the Sich, it is possible to take karbovantsiv on credit, meaning Cossack Vus can have a negative balance at some point. Additionally, Cossack Vus can use a single saber to capture multiple enemies.
Input
The first line contains two integers and () — the number of sabers and enemies, respectively.
The next lines each contain three integers , , and () — the length, sharpness, and cost of the -th saber.
The following lines each contain three integers , , and () — the thickness and strength of the -th enemy's armor and the reward for capturing them.
Output
Output a single integer — the maximum number of karbovantsiv Cossack Vus can earn.
Examples
Scoring
( points): For any two enemies , where , either , or , meaning there is no enemy whose both armor parameters are not worse than another; ;
( points): For any two enemies , where , either , or , meaning there is no enemy whose both armor parameters are not worse than another; ;
( points): For any two sabers , where , either , or , meaning there is no saber whose both attack parameters are not worse than another; ;
( points): For any two sabers , where , either , or , meaning there is no saber whose both attack parameters are not worse than another; ;
( points): ;
( points): ;
( points): Without additional constraints.
"'