The government is planning to build a walkway for tourists in the middle
of an oak forest. The forest can be represented as plane with special
lattice points representing oaks.
The walkway is represented as a rectangle with sides parallel to the axes. If the sides of walkway rectangle intersect any oak lattice points, such oaks need to be axed down. Oaks inside the rectangle do not represent problems and need not be cut down.
Ljubo is the state secretary of Forestry and a passionate nature lover,
so he ordered the secretary of Tourism to provide him with a list of
possible rectangle walkways that are attractive enough to draw in
tourists.
Ljubo plans to select the walkway that needs the smallest amount of oak trees to be cut down. Since we also like trees, would you be so kind and write a program that will determine the number of oaks that will be cut down for each walkway. Remember only the oaks intersecting the sides of the rectangle need to be cut.
Input Specification
The first line of input contains one integer
, number
of oaks.
The next lines contain two integers each
and
coordinates of oaks. There will be at most one oak on each lattice
point.
The next line contains one integer
, number of
walkways.
The next lines contain four integers each
,
,
and
coordinates of the lower left
and upper right
corner of the rectangle.
Output Specification
Output integers, one per line, the number of oaks that need to be cut
down for each walkway in the order they are presented in the input.
Scoring
Test data worth of points has
.
Test data worth of points has
.
Sample Input
6
1 2
3 2
2 3
2 5
4 4
6 3
4
2 2 4 4
2 2 6 5
3 3 5 6
5 1 6 6
Sample Output
3
4
0
1

Comments