402822: GYM100889 F Flipping Rectangles

Memory Limit:256 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Flipping Rectanglestime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given 2 coordinate axis aligned rectangles R1 and R2. You can apply at most K moves on R1.

A move is defined as follows: You can choose any of the four edges E of the current configuration of R1 and flip(reflect) R1 about E. E can be different in each move. For example, if R1 is currently between denoted by bottom-left and top-right corners by (0, 0) and (1, 1) and we flip it about the right edge(i.e. edge between (1, 1) and (1, 0)) then the configuration of R1 will be between (1, 0) and (2, 1).

Let A be the area of overlap of R2 and final configuration of R1. What is the maximum overlap area you can achieve?

Input

The first line contains T(1 ≤ T ≤ 105), the number of test cases. Every test cases has three lines of input. First line has four integers Sx, Sy, Sw, Sh, where (Sx, Sy) are the x and y coordinates of the bottom-left corner of the R1 rectangle. Sw is its width (along x-axis) and Sh is its height(along y-axis). Next line has four integers Dx, Dy, Dw, Dh representing the R2 rectangle in a similar fashion. Next line has one integer K(0 ≤ K ≤ 109). Absolute value of all coordinates doesn't exceed 109. Width and height lie between 1 and 109(both inclusive).

Output

Output for each query, the maximum overlap area you can achieve.

ExampleInput
1
0 0 10 10
20 20 5 10
0
Output
0
Note

Sample test case 1:

There is no overlap initially and we can't make any move.

加入题单

算法标签: