problem-1-20

Pravah is the annual Techno-Cultural Festival Of SKIT, and students of all streams are provided an opportunity to participate in the event by showcasing their entrepreneurial skills.
Each student is allotted a rectangular kiosk in the SKIT's rectangular event's field and their are multiple pipes on the field.
Each kiosk which has a pipe under its area is compensated as compared to kiosk which does not have any pipe segment under its area but is intersected by one or more pipe(s).
No two kiosk share common area i.e. no intersection of any two kiosks.
This means no two kiosks share any common points (including their borders).
You must compute two values:
the total area of the kiosks that contain at least one endpoint of a pipe segment
and the total area of the kiosks that do not contain any endpoints but are intersected by one or more pipes

The sides of the kiosks are parallel to the coordinate axes.  A pipe segment intersects a kiosk if they share at least one common point. This common point can be a pipe's endpoint or a point on the kiosk's border. A kiosk contains a point if it lies within the boundary of the kiosk and does not lie on its border. 

Input :

First line of input contains an integer T, denoting number of test cases.
Each test case's first line of input contains two integers K and P, denoting number of kiosks and pipes.
It is followed by K lines of input, each of which contains 4 space separated integers in the format "X1 Y1 X2 Y2" (quotes for clarity), where (X1, Y1) are the coordinates of the lower left corner of a kiosk and (X2, Y2) are the coordinates of its upper right corner.

After it P lines of input follows, each of which contains 4 space separated integers in the format "X1 Y1 X2 Y2", where (X1, Y1) and (X2, Y2) are the two endpoints of a pipe segment.

Output :

Print two space separated integers for each test case as mentioned in the problem statement.

SAMPLE INPUT
2
1 1
-1000 -1000 1000 1000
-525 245 222 243
4 1	
1 1 2 2
1 4 2 5
5 5 6 7
7 7 9 9
1 2 1 5

SAMPLE OUTPUT
4000000 0
0 2

Explanation

Test Case #1:

The only kiosk contains both ends of the only pipe. Hence the area of the first type kiosks is 2000 X 2000 and there is no other type of kiosks, hence 0

Test Case #2:

The only segment intersects kiosk 1 and 2. Hence the area is 0 for first type of kiosks and 2 for second type of kiosks.

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: