Doctor Y, always eager to further his research in the field of boxology, is observing a family of boxen in their natural habitat - a barrel of wine. He has noticed that in addition to the N (1 ≤ N ≤ 200,000) rectangular, two-dimensional boxen, there are M (1 ≤ M ≤ 200,000) almost imperceptible points floating on the surface of the wine. He reasons that these must be baby boxen - also known as boxlings.
Curious as to the customs of box families, Doctor Y wishes to count how many boxlings are floating on top of boxne. From his top-down view of the barrel, he has divided the surface of the wine into a two-dimensional Catersian plane, and noted the positions of all the boxen and boxlings. Each box occupies a rectangular region parallel to the axes of the plane, with its lower-left corner at (x1, y1) and its upper-right corner at (x2, y2), such that (-108 ≤ x1 < x2 ≤ 108) and (-108 ≤ y1 < y2 ≤ 108). Doctor Y has observed that boxen sometimes overlap one another. Each boxling is so small that it occupies only a single point on the plane, with x-coordinate a and y-coordinate b, such that (-108 ≤ a, b ≤ 108).
Having recorded the locations of all the life forms on the surface of the wine, Doctor Y is interested in counting exactly how many boxlings are floating on top of at least one box. Note that if a boxling is on the very edge or corner of a box, it counts as being on top. Also note that two boxlings can occupy the exact same locations, and that they should be counted separately.
With so many boxen and boxlings living in this wine barrel, Doctor Y doesn't feel like sitting there and counting them all by hand, crazy though he is. As such, he wants you to write a program to, given the locations of all the boxen and boxlings, count the number of boxlings that are floating on top of at least one box. Don't worry; your hard work will surely lead to exciting discoveries in the field of boxology.
|Line 1:||Two integers - N and M|
|The next N lines:||Four integers - x1, y1, x2 and y2|
|The next M lines:||Two integers a and b|
A single integer - the number of boxlings that are on top of at least one box.
5 10 -1 -1 2 5 4 -3 5 3 1 2 4 4 5 -6 8 -4 1 -2 8 0 1 4 5 4 2 2 3 1 6 -5 5 -1 3 -3 -1 -2 -1 -1 2 -1
Below is a top-down view of the surface of the wine:
The coloured-in squares are the boxen, the red dots are boxlings that are on top of at least one box, and the blue dots are the other boxlings. Counting the red dots, it can be seen that there are six of them.
Point Value: 20 (partial)
Time Limit: 3.00s
Memory Limit: 256M
Added: May 30, 2009
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3