题目描述
Problem Background
Zeromaker is not very skilled, but he loves playing the Touhou Project, especially the extra stages.
Problem Description
Zeromaker has a deep understanding of controlling the visibility of danmaku. Each danmaku appears within a specific time frame in Zeromaker's field of view, and outside of that time, it is in a place he cannot see. In Zeromaker's view, the more danmaku visible in his field of view, the harder the stage becomes, due to reasons he finds challenging. Now, Zeromaker wants to evaluate the difficulty of a stage. He already knows when each danmaku will appear in his field of view, and he wants to know how many danmaku have appeared in his field of view during a given period.
Input Format
The first line contains two integers $n$ and $m$, indicating there are $n$ danmaku and $m$ questions from Zeromaker.
The next $n$ lines, each containing two numbers $a$ and $b$, indicate that this danmaku appears in Zeromaker's field of view at $a$ seconds and lasts for $b$ seconds. The following $m$ lines, each containing two integers $x$ and $y$, indicate the period starting from $x$ seconds and lasting for $y$ seconds, asking how many danmaku have appeared during this time.
Note: The query interval is closed at both ends, and the danmaku appearance interval is open at both ends.
Output Format
$m$ lines, each being the answer to one of Zeromaker's questions.
Sample Input and Output
Sample Input #1
3 2
2 5
0 10
5 8
0 6
8 2
Sample Output #1
3
2
Sample Input #2
1 2
0 10
9 1
10 1
Sample Output #2
1
0
Notes
- $30\%$ of the data: $n, m \le 10^3$.
- $100\%$ of the data: $1 \le n, m \le 10^5$, $0 \le x, y, a, b \le 2^{31} - 1$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分