402791: GYM100883 B Rectangles

Memory Limit:64 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Rectanglestime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

You have N rectangles, all of their sides are either parallel to X axis or to Y axis, and you want to cover them all using one big rectangle.

what is the minimum area of the big rectangle you need in order to cover all the rectangles.

Input

The first line contains number of test cases T

Each test case consists of an integer N (1 ≤ N ≤ 1000), followed by N lines, each line describes a rectangle with four pairs of integers representing the X coordinate and Y coordinate of the vertices.  - 1000 ≤ Xcoordinate, Ycoordinate ≤ 1000

Output

For each test case print one integer which is the size of the rectangular cover.

ExamplesInput
2
1
1 1 2 2 2 1 1 2
2
0 0 10 5 0 5 10 0
0 1 1 1 1 0 0 0
Output
1
50

加入题单

上一题 下一题 算法标签: