Hide

RectSect

A common operation in computer graphics is to compute the intersection of two objects. For this problem, you need to compute the intersection of a set of rectangles that are to be drawn to the screen.

Input

Input begins with a line containing an integer $1 \le c \le 100$ indicating the number of test cases that follow. Each test case begins with a line with the number of rectangles $1 \le n \le 100$, followed by $n$ lines denoting coordinates left, top, right, and bottom. Coordinates are all integers, representing pixels, in the range $[0, 10\, 000]$. Top and right are positive directions.

Output

For each case, print the area of the intersection of all the given rectangles. The area of any one rectangle is its width (right-left) times its height (top-bottom).

Sample Input 1 Sample Output 1
2
3
0 7 8 0
3 7 7 1
5 10 9 4
2
1 2 2 1
0 3 3 0
6
1
CPU Time limit 1 second
Memory limit 1024 MB
Statistics Show
Author
Greg Hamerly
Source Baylor Competitive Learning course
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in