Codeforces Round 524 (Div. 2)
C
Masha and two friends
Codeforces
1500
原题
← BD →
翻译中…

Recently, Masha was presented with a chessboard with a height of $n$ and a width of $m$.

翻译中…

The rows on the chessboard are numbered from $1$ to $n$ from bottom to top. The columns are numbered from $1$ to $m$ from left to right. Therefore, each cell can be specified with the coordinates $(x,y)$, where $x$ is the column number, and $y$ is the row number (do not mix up).

翻译中…

Let us call a rectangle with coordinates $(a,b,c,d)$ a rectangle lower left point of which has coordinates $(a,b)$, and the upper right one — $(c,d)$.

翻译中…

The chessboard is painted black and white as follows:

翻译中…

image

翻译中…

An example of a chessboard.

翻译中…

Masha was very happy with the gift and, therefore, invited her friends Maxim and Denis to show off. The guys decided to make her a treat — they bought her a can of white and a can of black paint, so that if the old board deteriorates, it can be repainted. When they came to Masha, something unpleasant happened: first, Maxim went over the threshold and spilled white paint on the rectangle $(x_1,y_1,x_2,y_2)$. Then after him Denis spilled black paint on the rectangle $(x_3,y_3,x_4,y_4)$.

翻译中…

To spill paint of color $color$ onto a certain rectangle means that all the cells that belong to the given rectangle become $color$. The cell dyeing is superimposed on each other (if at first some cell is spilled with white paint and then with black one, then its color will be black).

翻译中…

Masha was shocked! She drove away from the guests and decided to find out how spoiled the gift was. For this, she needs to know the number of cells of white and black color. Help her find these numbers!

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 10^3$) — the number of test cases.

翻译中…

Each of them is described in the following format:

翻译中…

The first line contains two integers $n$ and $m$ ($1 \le n,m \le 10^9$) — the size of the board.

翻译中…

The second line contains four integers $x_1$, $y_1$, $x_2$, $y_2$ ($1 \le x_1 \le x_2 \le m, 1 \le y_1 \le y_2 \le n$) — the coordinates of the rectangle, the white paint was spilled on.

翻译中…

The third line contains four integers $x_3$, $y_3$, $x_4$, $y_4$ ($1 \le x_3 \le x_4 \le m, 1 \le y_3 \le y_4 \le n$) — the coordinates of the rectangle, the black paint was spilled on.

翻译中…

Output

翻译中…

Output $t$ lines, each of which contains two numbers — the number of white and black cells after spilling paint, respectively.

翻译中…

Note

翻译中…

Explanation for examples:

翻译中…

The first picture of each illustration shows how the field looked before the dyes were spilled. The second picture of each illustration shows how the field looked after Maxim spoiled white dye (the rectangle on which the dye was spilled is highlighted with red). The third picture in each illustration shows how the field looked after Denis spoiled black dye (the rectangle on which the dye was spilled is highlighted with red).

翻译中…

In the first test, the paint on the field changed as follows:

翻译中…

image

翻译中…

In the second test, the paint on the field changed as follows:

翻译中…

image

翻译中…

In the third test, the paint on the field changed as follows:

翻译中…

image

翻译中…

In the fourth test, the paint on the field changed as follows:

翻译中…

image

翻译中…

In the fifth test, the paint on the field changed as follows:

翻译中…

image

翻译中…

样例

Input #1
5
2 2
1 1 2 2
1 1 2 2
3 4
2 2 3 2
3 1 4 3
1 5
1 1 5 1
3 1 5 1
4 4
1 1 4 2
1 3 4 4
3 4
1 2 4 2
2 1 3 3
Output #1
0 4
3 9
2 3
8 8
4 8
InputCopy OutputCopy
题目信息
题号
1080C
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。