#p2822. 习题7.6.4 火车统计

习题7.6.4 火车统计

题目描述

自西向东延伸的铁路上坐落着NN个城市,现有MM列火车,

给出它们的出发城市 LiL_i 和目标城市 RiR_i1<=i<=m1 <= i <= m,

回答QQ次询问,每次询问给出pip_iqiq_i,输出出发城市序号大于等于pip_i且目标城市序号小于等于qiq_i的火车的数量。

输入格式

Input is given from Standard Input in the following format:

N N M M Q Q

L1 L_1 R1 R_1

L2 L_2 R2 R_2

: :

LM L_M RM R_M

p1 p_1 q1 q_1

p2 p_2 q2 q_2

: :

pQ p_Q qQ q_Q

输出格式

Print Q Q lines.

The i i -th line should contain the number of the trains that runs strictly within the section from City pi p_i to City qi q_i .

样例数据

inputinput


2 3 1

1 1

1 2

2 2

1 2

outputoutput


3

inputinput


10 3 2

1 5

2 8

7 10

1 7

3 10

outputoutput


1

1

inputinput


10 10 10

1 6

2 9

4 5

4 7

4 7

5 8

6 6

6 7

7 9

10 10

1 8

1 9

1 10

2 8

2 9

2 10

3 8

3 9

3 10

1 10

outputoutput


7

9

10

6

8

9

6

7

8

10

数据规模与约定

  • N N is an integer between 1 1 and 500 500 (inclusive).

  • M M is an integer between 1 1 and 200 000 200\ 000 (inclusive).

  • Q Q is an integer between 1 1 and 100 000 100\ 000 (inclusive).

  • 1  Li  Ri  N 1\ \leq\ L_i\ \leq\ R_i\ \leq\ N (1  i  M) (1\ \leq\ i\ \leq\ M)

  • 1  pi  qi  N 1\ \leq\ p_i\ \leq\ q_i\ \leq\ N (1  i  Q) (1\ \leq\ i\ \leq\ Q)

时间限制:1s1 \text {s}

空间限制:256MB256 \text {MB}