#438. Restore Atlantis II
Restore Atlantis II
Description
There are ancient Greek maps describing the fabled islands Atlantis. The maps are labeled by . The -th map shows the rectangle area is a part of Atlantis. The sides of all rectangles are parallel to the axes. There may be multiple islands, and the rectangles may overlap.
Unfortunately, some maps are even unreliable so they will not be considered. You will be given queries. In the -th query, you will be given two integers and (). Please write a program to figure out the total area of Atlantis when only maps labeled by () are reliable.
Format
Input
The first line contains a single integer (), the number of test cases. For each test case:
The first line of the input contains two integers and (), denoting the number of maps and the number of queries.
In the next lines, the -th line contains four integers , , and (, ), describing the -th map . is the southwest corner of , and is the northeast corner of .
In the next lines, the -th line contains two integers and (), describing the -th query.
It is guaranteed that all the values of , , , , and are chosen uniformly at random from integers in their corresponding ranges. The randomness condition does not apply to the sample test case, but your solution must pass the sample as well.
Output
For each query, print a single line containing an integer, denoting the total area using the information of all reliable maps in this query.
Samples
1
3 6
10 10 20 20
12 12 22 22
15 15 25 25
1 1
2 2
3 3
1 2
2 3
1 3
100
100
100
136
151
187