Area Coverage
In this day and age, a lot of the spying on other countries is done with the use of satellites and drones equipped with cameras. All these photographs of various sizes and from various sources can be combined to give a picture of the country as a whole.
Given the photographs (that is to say, the rectangular area covered by each, since the contents of the photographs themselves are of course top-secret!), can you work out what the total area is of all that is photographed? Note that certain areas can appear on multiple photographs and should be counted only once.
Input
First line contains number of test cases, at most 100. After that per test case:
first line contains number of photographs n (1 ≤ n ≤ 1000).
n lines with four space-separated integers
x[1]
,y[1]
,x[2]
andy[2]
(0 ≤x[1]
,y[1]
,x[2]
,y[2]
≤10^6
,x[1]
<x[2]
иy[1]
<y[2]
): the coordinates of the southwest and northeast corner respectively for each photograph. The photographs are all rectangular in shape with their other corners at (x[1]
,y[2]
) and (x[2]
,y[1]
).
The coordinates correspond to a flat two-dimensional space (i.e. we assume the Earth to be flat).
Output
For each test case print in one line the total area of all that appears on the photographs.