Recently, Masha was presented with a chessboard with a height of nn and a width of mm.

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

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

The chessboard is painted black and white as follows:

C. Masha and two friends_容斥定理

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 (x1,y1,x2,y2)(x1,y1,x2,y2). Then after him Denis spilled black paint on the rectangle (x3,y3,x4,y4)(x3,y3,x4,y4).

To spill paint of color colorcolor onto a certain rectangle means that all the cells that belong to the given rectangle become colorcolor. 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 tt (1≤t≤1031≤t≤103) — the number of test cases.

Each of them is described in the following format:

The first line contains two integers nn and mm (1≤n,m≤1091≤n,m≤109) — the size of the board.

The second line contains four integers x1x1, y1y1, x2x2, y2y2 (1≤x1≤x2≤m,1≤y1≤y2≤n1≤x1≤x2≤m,1≤y1≤y2≤n) — the coordinates of the rectangle, the white paint was spilled on.

The third line contains four integers x3x3, y3y3, x4x4, y4y4 (1≤x3≤x4≤m,1≤y3≤y4≤n1≤x3≤x4≤m,1≤y3≤y4≤n) — the coordinates of the rectangle, the black paint was spilled on.

Output

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

Example

input

Copy

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

Copy

0 4
3 9
2 3
8 8
4 8

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:

C. Masha and two friends_sed_02

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

C. Masha and two friends_容斥定理_03

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

C. Masha and two friends_技术_04

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

C. Masha and two friends_#include_05

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

C. Masha and two friends_ide_06

 

题目大意:给定一个n x m大小的由黑白方格组成的矩阵,左下角(1,1)处为白色方格,每个相邻方格颜色都不一样。再给你两个矩形的左下角和右上角坐标,把第一个的矩形内的所有方格染成白色,第二个矩形内的所有方格染成黑色。输出最后矩阵中有多少个白色方格和黑色方格

挺有意思的一个数学题,容斥定理吧,本人太菜,做了很久才做出来,不过做出来的一瞬间特别开心~~~

直接贴代码有注释

//C
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
ll  get(ll n,ll m)
{
	if(n<=0||m<=0) return 0;
	ll wh,bl;
	if(m%2==0)
	{
		wh=n*m/2;
		bl=n*m-wh;
	}
	else
	{
		if(n%2==1)
		{
			wh=(n+1)/2*(m+1)/2+(n/2)*(m/2);
			bl=n*m-wh;
		}
		else
		{
			wh=n*m/2;
			bl=n*m-wh;
		}
	}
	return wh;
}
int main()
{
	int _;
	scanf("%d",&_);
	while(_--)
	{
		ll n,m;
		ll n1,m1; 
		ll wh,bl;
		scanf("%lld%lld",&n1,&m1);
		//计算出最原始的黑色和白色数量
		wh=get(n1,m1);
		bl=n1*m1-wh;
		ll a,b,c,d;
		ll a1,b1,c1,d1;
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);//染成白色的矩形 
		scanf("%lld%lld%lld%lld",&a1,&b1,&c1,&d1);//染成黑色 
		//求相交矩形内的白色和黑色 
		ll x=min(c,c1)-max(a,a1)+1;
		ll y=min(d,d1)-max(b,b1)+1;
		ll wh3=get(x,y);
		ll bl3;
		if(wh3!=0)	bl3=x*y-wh3;
		else bl3=0;
		if((max(a,a1)+max(b,b1))%2==1) swap(wh3,bl3);
		//printf("相交的白色:%d,黑色:%d\n",wh3,bl3);
		ll wh1,bl1;
		ll wh2,bl2;
		//求染成白色矩形信息 
		n=c-a+1,m=d-b+1;
		wh1=get(n,m);
		bl1=n*m-wh1;
		if((a+b)%2==1)	swap(wh1,bl1);
		//求染成黑色矩形的信息 
		n=c1-a1+1,m=d1-b1+1;
		wh2=get(n,m);
		bl2=n*m-wh2;
		if((a1+b1)%2==1)	swap(wh2,bl2);
		//总结 
		wh1-=wh3;
		bl1-=bl3;
		wh=wh+bl1-wh2;
		bl=bl-bl1+wh2;
		printf("%lld %lld\n",wh,bl);
	}
}