题目描述
A cricket match is going to be held. The field is represented by a 1D plane. A cricketer, Mr. X has $N$ favorite shots. Each shot has a particular range.
The range of the $i^{\mbox{th}}$ shot is from $\mbox{A}_{i}$ to $\mbox{B}_{i}$. That means his favorite shot can be anywhere in this range. Each player on the opposite team
can field only in a particular range. Player $\boldsymbol{i}$ can field from $\mbox{C}_{i}$ to $\mbox{D}_{i}$. You are given the $N$ favorite shots of Mr. X and the range of $\mbox{M}$ players.
$\mbox{S}_i$ represents the strength of each player i.e. the number of shots player $\boldsymbol{i}$ can stop.
Your task is to find:
$\left(\textstyle\sum_{i=1}^{m}S i\right)$.
Game Rules: A player can stop the $i^{\mbox{th}}$ shot if the range overlaps with the player's fielding range.
For more clarity about overlapping, study the following figure:
Input Format
The first line consists of two space separated integers, $N$ and $\mbox{M}$.
Each of the next $N$ lines contains two space separated integers. The $i^{\mbox{th}}$ line contains $A_i$ and $B_i$.
Each of the next $\mbox{M}$ lines contains two integers. The $i^{\mbox{th}}$ line contains integers $C_i$ and $D_i$.
Output Format
You need to print the sum of the strengths of all the players: $\left(\textstyle\sum_{i=1}^{m}S i\right)$.
Constraints:
$1\leq N,M\leq10^5$
$1\leq A_i,B_i,C_i,D_i\leq10^8$
Sample Input
4 4
1 2
2 3
4 5
6 7
1 5
2 3
4 7
5 7
Sample Output
9
Explanation
Player 1 can stop the 1st, 2nd and 3rd shot so the strength is $3$.
Player 2 can stop the 1st and 2nd shot so the strength is $2$.
Player 3 can stop the 3rd and 4th shot so the strength is $2$.
Player 4 can stop the 3rd and 4th shot so the strength is $2$.
The sum of the strengths of all the players is $3+2+2+2=9$.
输入格式
见题面
输出格式
见题面