2273: Total Area

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:21 解决:1

题目描述

There are two rectangles on the same plane and their sides are parallel to x-axis and y-axis. You are given the coordinates of two points on the diagonals of each rectangle. Now you need to count the total area of these two rectangles. Please don't count the area of the intersected part of two rectangles twice.

输入

  The first line of the input file contains one integer T which is the number of test cases following. Each test case contains 8 integers which are the coordinates of four points which are metioned before. These 8 numbers are x1,y1,x3,y3,x2,y2,x4,y4. (x1,y1) and (x2,y2) are the points on the first retangle. (x3,y3) and (x4,y4) are the points on the second retangle.
  What's more, -1000000<= xi, yi(1<=i<=4) <= 1000000.

输出

  Output the total area of two rectangles for each case in a single line.

样例输入 复制

1
0 0 2 2 2 2 1 1

样例输出 复制

4

提示

In the sample input, there are two rectangles: A and B.  Rectangle A is (0,0)-(0,2)-(2,2)-(2,0) and its area is 4.  Rectangle B is (1,1)-(1,2)-(2,2)-(2,1) and its area is 1. The common area of A and B is 1. So the total area of A and B is 4. (4+1-1=4)