Problem1470--Double seaweeds

1470: Double seaweeds

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1  Solved: 1
[Submit] [Status] [Web Board] [Creator:]

Description

Raya was fishing when she found seaweed floating on the surface. (This tells us that she was fishing in the ocean.)
But suddenly, the seaweed had a beautiful and harmonious color. When she looked closely, she saw that there were two seaweeds overlapping in that area.
Raya was curious about the area of the harmonious area created by the two seaweeds overlapping.
Seaweed is a square shape parallel to the x-axis and y-axis on a 2D plane, and the two vertices connected diagonally are expressed as a total of four integers. (x and y-coordinate of the first vertex, x and y-coordinate of the second vertex in that order)

Input

The input consists of several test cases. The first line contains the number of test cases, T. 
Starting from the second line, each line contains eight integers (greater than -10,000 and less than 10,000) representing two seaweed sheets, one test case. The first four integers represent the first seaweed sheet, and the last four integers represent the second seaweed sheet.

Output

Print the answer to each test case, one per line.

Sample Input Copy

2
1 1 3 3 2 2 4 4
1 1 2 2 3 3 4 4

Sample Output Copy

1
0

Source/Category