#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct student
{
	long long charge;
	long long usage;
	bool operator <(const student& r)const { return charge / usage > r.charge / r.usage; }
}s[200005];
int n, k;
bool judge(long long power)
{
	priority_queue<student> q;
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; i++)
	{
		q.push(student{ s[i].charge,s[i].usage });
	}
	student temp;
	for (int i = 1; i <= k; i++)
	{
		temp = q.top();
		q.pop();
		if (temp.charge / temp.usage < i - 1) return false;
		temp.charge += power;
		q.push(temp);
	}
	return true;
}
int main()
{
	while (scanf("%d%d",&n,&k)!=EOF)
	{
		for (int i = 1; i <= n; i++)scanf("%I64d", &s[i].charge);
		for (int i = 1; i <= n; i++) scanf("%I64d", &s[i].usage);
		if (judge(1e13) == false)
		{
			cout << -1 << endl;
			continue;
		}
		else
		{
			long long l = 0, r = 1e13;
			while (l < r)
			{
				long long mid = (l + r) >> 1;
				if (!judge(mid))
				{
					l = mid + 1;
				}
				else
				{
					r = mid;
				}
			}
			cout << r << endl;
		}
	}
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const ll INF=1e9;
int n,K;
ll A[MAXN],B[MAXN],a[MAXN],b[MAXN];
struct RULE{
	bool operator()(const int &x,const int &y)const{
		if(a[x]/b[x]!=a[y]/b[y])return a[x]/b[x]>a[y]/b[y];
		else return b[x]<b[y];
	}
};
bool check(ll mid){
	priority_queue<int,vector<int>,RULE>q;
	for(int i=1;i<=n;++i)a[i]=A[i],b[i]=B[i],q.push(i);
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top();q.pop();
		if(a[i]/b[i]<t-1)return false;
		a[i]+=mid;
		if(a[i]/b[i]>=K)continue;
		q.push(i);
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)B[i]=read();
	ll l=0,r=INF;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%lld\n",l);
	else printf("%d\n",-1);
	return 0;
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const ll INF=2e12;
int n,K,b[MAXN];
ll A[MAXN],a[MAXN];
bool check(ll mid){
	priority_queue<pii,vector<pii>,greater<pii> >q;
	for(int i=1;i<=n;++i)a[i]=A[i],q.push(mk(a[i]/b[i],i));
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top().scd;q.pop();
		if(a[i]/b[i]<t-1)return false;
		a[i]+=mid;
		if(a[i]/b[i]>=K)continue;
		q.push(mk(a[i]/b[i],i));
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)b[i]=read();
	ll l=0,r=INF;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%lld\n",l);
	else printf("%d\n",-1);
	return 0;
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const ll INF=1e9;
int n,K;
ll A[MAXN],B[MAXN],a[MAXN],b[MAXN];
struct RULE{
	bool operator()(const int &x,const int &y)const{
		if(a[x]/b[x]!=a[y]/b[y])return a[x]/b[x]>a[y]/b[y];
		else return b[x]<b[y];
	}
};
bool check(ll mid){
	priority_queue<int,vector<int>,RULE>q;
	for(int i=1;i<=n;++i)a[i]=A[i],b[i]=B[i],q.push(i);
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top();q.pop();
		if(a[i]/b[i]<t-1)return false;
		a[i]+=mid;q.push(i);
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)B[i]=read();
	ll l=1,r=INF;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%lld\n",l);
	else printf("%d\n",-1);
	return 0;
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const ll INF=1e9;
int n,K;
ll A[MAXN],B[MAXN],a[MAXN],b[MAXN];
struct RULE{
	bool operator()(const int &x,const int &y)const{
		if(a[x]/b[x]!=a[y]/b[y])return a[x]/b[x]>a[y]/b[y];
		else return b[x]<b[y];
	}
};
bool check(ll mid){
	priority_queue<int,vector<int>,RULE>q;
	for(int i=1;i<=n;++i)a[i]=A[i],b[i]=B[i],q.push(i);
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top();q.pop();
		if(a[i]/b[i]<t-1)return false;
		a[i]+=mid;q.push(i);
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)B[i]=read();
	ll l=0,r=INF;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%lld\n",l);
	else printf("%d\n",-1);
	return 0;
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const ll INF=2e12;
int n,K,b[MAXN];
ll A[MAXN],a[MAXN];
struct RULE{
	bool operator()(const int &x,const int &y)const{
		if(a[x]/b[x]!=a[y]/b[y])return a[x]/b[x]>a[y]/b[y];
		else return b[x]<b[y];
	}
};
bool check(ll mid){
	priority_queue<int,vector<int>,RULE>q;
	for(int i=1;i<=n;++i)a[i]=A[i],q.push(i);
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top();q.pop();
		if(a[i]/b[i]<t-1)return false;
		a[i]+=mid;
		if(a[i]/b[i]>=K)continue;
		q.push(i);
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)b[i]=read();
	ll l=0,r=INF;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%lld\n",l);
	else printf("%d\n",-1);
	return 0;
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const ll INF=2e12;
int n,K,b[MAXN];
ll A[MAXN],a[MAXN];
struct RULE{
	bool operator ()(const pii &x,const pii &y)const{
		return x.fst>y.fst||(x.fst==y.fst&&b[x.scd]<b[y.scd]);
	}
};
bool check(ll mid){
	priority_queue<pii,vector<pii>,RULE>q;
	for(int i=1;i<=n;++i)a[i]=A[i],q.push(mk(a[i]/b[i],i));
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top().scd;q.pop();
		if(a[i]/b[i]<t-1)return false;
		a[i]+=mid;
		if(a[i]/b[i]>=K)continue;
		q.push(mk(a[i]/b[i],i));
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)b[i]=read();
	ll l=0,r=INF;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%lld\n",l);
	else printf("%d\n",-1);
	return 0;
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const ll INF=2e12;
int n,K,b[MAXN];
ll A[MAXN],a[MAXN];
//struct RULE{
//	bool operator ()(const pii &x,const pii &y)const{
//		return x.fst>y.fst||(x.fst==y.fst&&b[x.scd]<b[y.scd])||(x.fst==y.fst&&b[x.scd]==b[y.scd]&&a[x.scd]>a[y.scd]);
//	}
//};
bool check(ll mid){
	priority_queue<pll,vector<pll>,greater<pll> >q;
	for(int i=1;i<=n;++i){a[i]=A[i];if(a[i]/b[i]<K)q.push(mk(a[i]/b[i],i));}
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top().scd;q.pop();
		if(a[i]/b[i]<t-1)return false;
		if(a[i]/b[i]<K)a[i]+=mid,q.push(mk(a[i]/b[i],i));
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)b[i]=read();
	ll l=0,r=INF;
	while(l<r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%lld\n",l);
	else printf("%d\n",-1);
	return 0;
}


#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define y0 pmt
#define y1 pmtpmt
#define x0 pmtQAQ
#define x1 pmtQwQ
//#define getchar nc

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int > vi;
typedef pair<ll ,ll > pii;
//typedef pair<ll,<ll,ll> > piii;
const int INF=0x3f3f3f3f, maxn=1000007, MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3fLL;
const ll P=19260817;
char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*f;
}
void write(int x){
    if(!x)putchar('0');if(x<0)x=-x,putchar('-');
    static int sta[20];register int tot=0;
    while(x)sta[tot++]=x%10,x/=10;
    while(tot)putchar(sta[--tot]+48);
}
int n;
ll k;
ll a[maxn],b[maxn];
ll rta[maxn],rtb[maxn];
struct node{
	ll x;
	int id;
	friend bool operator<(const node &a,const node &b){
		if(a.x!=b.x)return a.x>b.x;
		if(rtb[a.id]!=rtb[b.id])return rtb[a.id]<rtb[b.id];
		//return rta[a.id]<rta[b.id];
	}
};
priority_queue<node> q;
bool check(ll x){
	while(!q.empty())q.pop();
	for(int i=1;i<=n;i++){
		rta[i]=a[i],rtb[i]=b[i];
		if(a[i]/b[i]<k)q.push((node){a[i]/b[i],i});
	}
	if(q.empty())return true;
	for(int i=1;i<=k;i++){
		node rt=q.top();
		q.pop();
		int id=rt.id;
//		cout<<id<<' '<<rta[id]<<' '<<rtb[id]<<endl;
		if(rt.x<i-1)return false;
		if((rta[id]+x)/rtb[id]<k)rta[id]+=x,q.push((node){rta[id]/rtb[id],id});
		if(q.empty())return true;
	}
	return true;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",a+i);
	for(int i=1;i<=n;i++)scanf("%lld",b+i);
	ll l=0,r=1e13,ans=-1;
	while(l<=r){
		ll mid=(l+r)>>1;
		if(check(mid))r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


//problem:CF1132D
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2e5+5;
const int INF=2e7;
int n,K,b[MAXN];
ll A[MAXN],a[MAXN];
struct RULE{
	bool operator()(const int &x,const int &y)const{
		if(a[x]/b[x]!=a[y]/b[y])return a[x]/b[x]>a[y]/b[y];
		else return b[x]<b[y];
	}
};
bool check(int mid){
	priority_queue<int,vector<int>,RULE>q;
	for(int i=1;i<=n;++i)a[i]=A[i],q.push(i);
	for(int t=1;t<=K;++t){
		if(q.empty())return true;
		int i=q.top();q.pop();
		if(a[i]/b[i]<t-1)return false;
		a[i]+=mid;
		if(a[i]/b[i]>=K)continue;
		q.push(i);
	}
	return true;
}
int main() {
	n=read();K=read();
	for(int i=1;i<=n;++i)A[i]=readll();
	for(int i=1;i<=n;++i)b[i]=read();
	int l=0,r=INF;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	if(l!=INF)printf("%d\n",l);
	else printf("%d\n",-1);
	return 0;
}


#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define all(__vv__) (__vv__).begin(), (__vv__).end()
#define endl "\n"
#define pai pair<ll, pair<ll, ll> >
#define ms(__x__,__val__) memset(__x__, __val__, sizeof(__x__))
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())	s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void print(ll x, int op = 10) { if (!x) { putchar('0'); if (op)	putchar(op); return; }	char F[40]; ll tmp = x > 0 ? x : -x;	if (x < 0)putchar('-');	int cnt = 0;	while (tmp > 0) { F[cnt++] = tmp % 10 + '0';		tmp /= 10; }	while (cnt > 0)putchar(F[--cnt]);	if (op)	putchar(op); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;	while (b) { if (b & 1)	ans *= a;		b >>= 1;		a *= a; }	return ans; }	ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }
const int dir[][2] = { {0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;

const int N = 2e5 + 7;
ll n, k, a[N], b[N];

bool check(ll x) {
	priority_queue<pai, vector<pai>, greater<pai>> pq;
	for (int i = 1; i <= n; ++i)
		if (a[i] / b[i] < k)
			pq.push({ a[i] / b[i],{a[i],b[i]} });
	if (pq.empty())	return true;
	for (int i = 0; i < k; ++i) {
		ll C = pq.top().first, A = pq.top().second.first, B = pq.top().second.second;	pq.pop();
		if (C < i)	return false;
		if (A / B < k) {
			A += x;
			pq.push({ A / B,{A,B} });
		}
		if (pq.empty())	return true;
	}
	return true;
}

int main() {
	n = read(), k = read();
	for (int i = 1; i <= n; ++i)
		a[i] = read();
	for (int i = 1; i <= n; ++i)
		b[i] = read();
	ll l = 0, r = 1e13, ans = -1;
	while (l <= r) {
		ll mid = l + r >> 1;
		if (check(mid))
			ans = mid, r = mid - 1;
		else
			l = mid + 1;
	}
	print(ans);
	return 0;
}


#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define all(__vv__) (__vv__).begin(), (__vv__).end()
#define endl "\n"
#define pai pair<ll, pair<ll, ll> >
#define ms(__x__,__val__) memset(__x__, __val__, sizeof(__x__))
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())	s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void print(ll x, int op = 10) { if (!x) { putchar('0'); if (op)	putchar(op); return; }	char F[40]; ll tmp = x > 0 ? x : -x;	if (x < 0)putchar('-');	int cnt = 0;	while (tmp > 0) { F[cnt++] = tmp % 10 + '0';		tmp /= 10; }	while (cnt > 0)putchar(F[--cnt]);	if (op)	putchar(op); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;	while (b) { if (b & 1)	ans *= a;		b >>= 1;		a *= a; }	return ans; }	ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }
const int dir[][2] = { {0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;

const int N = 2e5 + 7;
ll n, k, a[N], b[N];

bool check(ll x) {
	priority_queue<pai, vector<pai>, greater<pai>> pq;
	for (int i = 1; i <= n; ++i)
		if (a[i] / b[i] < k)
			pq.push({ a[i] / b[i],{a[i],b[i]} });
	if (pq.empty())	return true;
	for (int i = 0; i < k; ++i) {
		ll C = pq.top().first, A = pq.top().second.first, B = pq.top().second.second;	pq.pop();
		if (C < i)	return false;
		if (A / B < k) {
			A += x;
			pq.push({ A / B,{A,B} });
		}
		if (pq.empty())	return true;
	}
	return true;
}

int main() {
	n = read(), k = read();
	for (int i = 1; i <= n; ++i)
		a[i] = read();
	for (int i = 1; i <= n; ++i)
		b[i] = read();
	ll l = 0, r = 1e18, ans = -1;
	while (l <= r) {
		ll mid = l + r >> 1;
		if (check(mid))
			ans = mid, r = mid - 1;
		else
			l = mid + 1;
	}
	print(ans);
	return 0;
}


#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#pragma GCC optimize("O2,O3,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define all(__vv__) (__vv__).begin(), (__vv__).end()
#define endl "\n"
#define pai pair<ll, pair<ll, ll> >
#define ms(__x__,__val__) memset(__x__, __val__, sizeof(__x__))
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())	s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void print(ll x, int op = 10) { if (!x) { putchar('0'); if (op)	putchar(op); return; }	char F[40]; ll tmp = x > 0 ? x : -x;	if (x < 0)putchar('-');	int cnt = 0;	while (tmp > 0) { F[cnt++] = tmp % 10 + '0';		tmp /= 10; }	while (cnt > 0)putchar(F[--cnt]);	if (op)	putchar(op); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;	while (b) { if (b & 1)	ans *= a;		b >>= 1;		a *= a; }	return ans; }	ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }
const int dir[][2] = { {0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;

const int N = 1e5 + 7;
ll n, k, a[N], b[N];

bool check(ll x) {
	priority_queue<pai, vector<pai>, greater<pai>> pq;
	for (int i = 1; i <= n; ++i)
		if (a[i] / b[i] < k)
			pq.push({ a[i] / b[i],{a[i],b[i]} });
	if (pq.empty())	return true;
	for (int i = 0; i < k; ++i) {
		ll C = pq.top().first, A = pq.top().second.first, B = pq.top().second.second;	pq.pop();
		if (C < i)	return false;
		if (A / B < k) {
			A += x;
			pq.push({ A / B,{A,B} });
		}
		if (pq.empty())	return true;
	}
	return true;
}

int main() {
	n = read(), k = read();
	for (int i = 1; i <= n; ++i)
		a[i] = read();
	for (int i = 1; i <= n; ++i)
		b[i] = read();
	ll l = 0, r = 1e13, ans = -1;
	while (l <= r) {
		ll mid = l + r >> 1;
		if (check(mid))
			ans = mid, r = mid - 1;
		else
			l = mid + 1;
	}
	print(ans);
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
long long x1,x2,x3,x4,y1,y2,y3,y4,ansx1,ansy1,ansx2,ansy2;
long long calc()
{
	if (x1>x3)
	{
		swap(x1,x3);
		swap(x2,x4);
		swap(y1,y3);
		swap(y2,y4);
	}
	if (x3>x2) return 0;
	long long x=min(x2,x4)-x3+1;
	ansx1=x3;
	ansx2=min(x2,x4);
	if (y1>y3)
	{
		swap(x1,x3);
		swap(x2,x4);
		swap(y1,y3);
		swap(y2,y4);
	}
	if (y3>y2) return 0;
	long long y=min(y2,y4)-y3+1;
	ansy1=y3;
	ansy2=min(y2,y4);
	return x*y;
}
int t,i,j;
long long n,m,sum,sbfsb,sgnsd,advava,sjrhgsd,p;
void scan()
{
        cin>>n>>m;
		cin>>x1>>y1>>x2>>y2;
		cin>>x3>>y3>>x4>>y4;
}
void init()
{
        sum=n*m;
		advava=sum/2+sum%2;
		sjrhgsd=sum/2;
		sbfsb=(x2-x1+1)*(y2-y1+1);
		sgnsd=(x4-x3+1)*(y4-y3+1);
		advava-=sbfsb/2;
		sjrhgsd-=sbfsb/2;
}
void solve()
{
    if (sbfsb%2!=0)
		{
			if ((x1+y1)%2==0) advava--;
			else sjrhgsd--;
		}
		advava-=sgnsd/2;
		sjrhgsd-=sgnsd/2;
		if (sgnsd%2!=0)
		{
			if ((x3+y3)%2==0) advava--;
			else sjrhgsd--;
		}
		p=calc();
/*
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int INF=1e9+5;
int read(int &a){scanf("%d",&a);return a;}
int read(){int a;scanf("%d",&a);return a;}
int main()
{
    int q;read(q);int l,r;int ans;
    while(q--)
    {
        read(l);
        read(r);
        if((r-l)&1)
        {
            ans=(r&1)?(-(r-l+1)/2):((r-l+1)/2);
        }
        else
        {
            ans=(r&1)?(-(r-l)/2-l):((r-l)/2+l);
        }
        printf("%d\n",ans);
    }
    return 0;
}
*/
	//	cout<<sbfsb<<' '<<sgnsd<<' '<<p<<' '<<advava<<' '<<sjrhgsd<<endl;
		advava+=sbfsb-p;
		sjrhgsd+=sgnsd;
		if (p!=0)
		{
            long long abhafb=(ansx2-ansx1+1)*(ansy2-ansy1+1);
            //cout<<abhafb<<' '<<ansx1<<' '<<ansy1<<' '<<ansx2<<' '<<ansy2<<endl;
            advava+=abhafb/2;
            sjrhgsd+=abhafb/2;
            if (abhafb%2!=0)
            {
                if ((ansx1+ansy1)%2==0) advava++;
                else sjrhgsd++;
            }
		}
}
int main()
{
	cin>>t;
	while (t--)
	{
		scan();
		init();
		solve();
		cout<<advava<<' '<<sjrhgsd<<endl;
	}
	return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e5+5;
const int INF=1e9+5;
int read(int &a){scanf("%d",&a);return a;}
int read(){int a;scanf("%d",&a);return a;}
int n,m,x1,x2,x3,x4,y1,y2,y3,y4;
long long len1,len2,len3,len4,white,black;
void cover(int x1,int y1,int x2,int y2)
{
    //cout<<x1<<y1<<x2<<y2<<endl;
    if(x2<x1)return;
    if(y2<y1)return;
    if(x1<=0)return;
    if(y1<=0)return;
    if(x2<=0)return;
    if(y2<=0)return;
    long long len1=x2-x1+1;
    long long len2=y2-y1+1;
    if((len1&1)&&(len2&1))
    {
            if((x1+y1)&1)
            {
                white+=(len1*len2/2+1);
                black-=(len1*len2/2+1);
            }
            else
            {
                white+=(len1*len2/2);
                black-=(len1*len2/2);
            }
    }
    else
    {
        white+=(len1*len2/2);
        black-=len1*len2/2;
    }
    //cout<<white<<' '<<black<<endl;
}
int main()
{
    int t;read(t);
    while(t--)
    {
        read(n);read(m);
        white=(1ll*n*m+1)/2;
        black=1ll*n*m/2;
        scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
        scanf("%d %d %d %d",&x3,&y3,&x4,&y4);
        len1=x2-x1+1;
        len2=y2-y1+1;
        len3=x4-x3+1;
        len4=y4-y3+1;
        if((len3&1)&&(len4&1))
        {
                if(!((x3+y3)&1))
                {
                    white-=(len3*len4/2+1);
                    black+=(len3*len4/2+1);
                }
                else
                {
                    white-=(len3*len4/2);
                    black+=(len3*len4/2);
                }
        }
        else
        {
            white-=(len3*len4/2);
            black+=len3*len4/2;
        }
         //cout<<white<<' '<<black<<endl;
        if(x2<x3&&y2<y3)
        {
            cover(x1,x2,y1,y2);
            /*
            if((len1&1)&&(len2&1))
            {
                    if((x1+x2)&1)
                    {
                        white+=(len1*len2/2);
                        black-=(len1*len2/2);
                    }

                    else
                    {
                        white+=(len1*len2/2+1);
                        black-=(len1*len2/2+1);
                    }
            }
            else
            {
                white+=(len1*len2/2);
                black-=len1*len2/2;
            }*/
        }
        else
        {
            if(!(x3<=x1&&y3<=y1))
            {
                cover(x1,y1,x3-1,y3-1);
                //cout<<white<<' '<<black<<endl;
                //if(x3>=x1)
                cover(max(x3,x1),y1,x2,y3-1);
                //cout<<white<<' '<<black<<endl;
                if(y3>=y1)
                cover(x1,y3,x3-1,y2);
                else
                cover(x1,y1,x3-1,y2);
                //cout<<white<<' '<<black<<endl;
            }
        }
        printf("%lld %lld\n",white,black);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e5+5;
const int INF=1e9+5;
int read(int &a){scanf("%d",&a);return a;}
int read(){int a;scanf("%d",&a);return a;}
int n,m,x1,x2,x3,x4,y1,y2,y3,y4,white,black;
long long len1,len2,len3,len4;
void cover(int x1,int y1,int x2,int y2)
{
    //cout<<x1<<y1<<x2<<y2<<endl;
    if(x2<x1)return;
    if(y2<y1)return;
    if(x1<=0)return;
    if(y1<=0)return;
    if(x2<=0)return;
    if(y2<=0)return;
    int len1=x2-x1+1;
    int len2=y2-y1+1;
    if((len1&1)&&(len2&1))
    {
            if((x1+y1)&1)
            {
                white+=(len1*len2/2+1);
                black-=(len1*len2/2+1);
            }
            else
            {
                white+=(len1*len2/2);
                black-=(len1*len2/2);
            }
    }
    else
    {
        white+=(len1*len2/2);
        black-=len1*len2/2;
    }
    //cout<<white<<' '<<black<<endl;
}
int main()
{
    int t;read(t);
    while(t--)
    {
        read(n);read(m);
        white=(1ll*n*m+1)/2;
        black=1ll*n*m/2;
        scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
        scanf("%d %d %d %d",&x3,&y3,&x4,&y4);
        len1=x2-x1+1;
        len2=y2-y1+1;
        len3=x4-x3+1;
        len4=y4-y3+1;
        if((len3&1)&&(len4&1))
        {
                if(!((x3+y3)&1))
                {
                    white-=(len3*len4/2+1);
                    black+=(len3*len4/2+1);
                }
                else
                {
                    white-=(len3*len4/2);
                    black+=(len3*len4/2);
                }
        }
        else
        {
            white-=(len3*len4/2);
            black+=len3*len4/2;
        }

         //cout<<white<<' '<<black<<endl;
        if(x2<x3&&y2<y3)
        {
            cover(x1,x2,y1,y2);
            /*
            if((len1&1)&&(len2&1))
            {
                    if((x1+x2)&1)
                    {
                        white+=(len1*len2/2);
                        black-=(len1*len2/2);
                    }

                    else
                    {
                        white+=(len1*len2/2+1);
                        black-=(len1*len2/2+1);
                    }
            }
            else
            {
                white+=(len1*len2/2);
                black-=len1*len2/2;
            }*/
        }
        else
        {
            cover(x1,y1,x3-1,y3-1);
            //cout<<white<<' '<<black<<endl;
            if(x3>=x1)
            cover(min(x3,x1),y1,x2,y3-1);
            //cout<<white<<' '<<black<<endl;
            if(y3>=y1)
            cover(x1,y3,x3-1,y2);
            else
            cover(x1,y1,x3-1,y2);
            //cout<<white<<' '<<black<<endl;
        }
        printf("%d %d\n",white,black);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> graph;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)(x.size()))
#define all(t) t.begin(),t.end()
#define in(x,y) ((y).find((x))!=(y).end())
#define remax(a,b) (a)=max((a),(b));
#define remin(a,b) (a)=min((a),(b));
#define forn(i,n) for(int (i)=0;(i)<(n);++(i))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define repd(i,a,b) for(int (i)=(a); (i)>=(b);--i)

// [](const int &lhs, const int &rhs) {return lhs > rhs; }
// [](const pii &lhs, const pii &rhs) {return lhs.fi < rhs.fi; }

#define dbg 0

bool is_point_in (int p_x, int p_y, int x_1, int y_1, int x_2, int y_2)
{
  return (p_x >= x_1 && p_x <= x_2 && p_y >= y_1 && p_y <= y_2);
}

bool is_h_segment_inter (int s_x_1, int s_y_1, int s_x_2, int s_y_2, int x_1, int y_1, int x_2, int y_2)
{
  return (s_x_1 < x_1 && s_x_2 > x_2 && s_y_1 > y_1 && s_y_2 < y_2);
}

bool is_w_segment_inter (int s_x_1, int s_y_1, int s_x_2, int s_y_2, int x_1, int y_1, int x_2, int y_2)
{
  return (s_x_1 > x_1 && s_x_2 < x_2 && s_y_1 < y_1 && s_y_2 > y_2);
}

bool intersect_poly (int a_x_1, int a_y_1, int a_x_2, int a_y_2, //< has bigger area
                    int b_x_1, int b_y_1, int b_x_2, int b_y_2, //< has smaller area
                    int &c_x_1, int &c_y_1, int &c_x_2, int &c_y_2)
{
  bool left_down = is_point_in (b_x_1, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);
  bool left_up = is_point_in (b_x_1, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right_up = is_point_in (b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right_down = is_point_in (b_x_2, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);

  if (left_down && left_up && right_up && right_down) // 4 points in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left_up && right_up) // 2 points in
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_up && right_down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_down && left_down) // 2 points in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (left_up && left_down) // 2 points in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left_up) // 1 point in
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_up) // 1 point in
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_down) // 1 point in
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (left_down) // 1 point in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }

  // if (!left_down && !left_up && !right_up && !right_down) // 0 points in
  bool left = is_w_segment_inter (b_x_1, b_y_1, b_x_1, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool up = is_h_segment_inter (b_x_1, b_y_2, b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right = is_w_segment_inter (b_x_2, b_y_1, b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool down = is_h_segment_inter (b_x_1, b_y_1, b_x_2, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);

  if (left && right)
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (up && down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left)
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (right)
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (up)
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }

  return false;
}

void board (int m, int n, int &w, int &b)
{
  w = (m % 2 ? (m / 2 + 1) * n : (m / 2) * n);
  b = (m / 2) * n;
}

void subboard (int x_1, int y_1, int x_2, int y_2, int &w, int &b)
{
  int m = x_2 + 1 - x_1;
  int n = y_2 + 1 - y_1;
  if (x_1 % 2 == 0 || y_1 % 2 == 0)
    board (m, n, b, w); //< black start
  else
    board (m, n, w, b); //< white start
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

#if dbg
  cout << endl;
  ifstream cin("input.txt");
#endif

  int n, m;
  int x_1_w, y_1_w, x_2_w, y_2_w;
  int x_1_b, y_1_b, x_2_b, y_2_b;
  int x_1_wb, y_1_wb, x_2_wb, y_2_wb;
  int t, w_res, b_res;
  cin >> t;
  while (t--)
    {
      cin >> n >> m;
      cin >> x_1_w >> y_1_w >> x_2_w >> y_2_w;
      cin >> x_1_b >> y_1_b >> x_2_b >> y_2_b;

      int w_initial = 0;
      int b_initial = 0;
      board (m, n, w_initial, b_initial);

      int w_1 = 0;
      int b_1 = 0;
      subboard (x_1_w, y_1_w, x_2_w, y_2_w, w_1, b_1);

      int w_2 = 0;
      int b_2 = 0;
      subboard (x_1_b, y_1_b, x_2_b, y_2_b, w_2, b_2);

      int w_3 = 0;
      int b_3 = 0;
      if ((ll) (x_2_w + 1 - x_1_w) * (ll) (y_2_w + 1 - y_1_w) >= (ll) (x_2_b + 1 - x_1_b) * (ll) (y_2_b + 1 - y_1_b))
        {
          if (intersect_poly (x_1_w, y_1_w, x_2_w, y_2_w, x_1_b, y_1_b, x_2_b, y_2_b, x_1_wb, y_1_wb, x_2_wb, y_2_wb))
            {
              subboard (x_1_wb, y_1_wb, x_2_wb, y_2_wb, w_3, b_3);
            }
        }
      else
        {
          if (intersect_poly (x_1_b, y_1_b, x_2_b, y_2_b, x_1_w, y_1_w, x_2_w, y_2_w, x_1_wb, y_1_wb, x_2_wb, y_2_wb))
            {
              subboard (x_1_wb, y_1_wb, x_2_wb, y_2_wb, w_3, b_3);
            }
        }

      w_res = w_initial + b_1 - w_2 - b_3;
      b_res = b_initial - b_1 + w_2 + b_3;

      cout << w_res << " " << b_res << endl;

    }

#if dbg
  cin.close ();
  cout << endl;
#endif
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> graph;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)(x.size()))
#define all(t) t.begin(),t.end()
#define in(x,y) ((y).find((x))!=(y).end())
#define remax(a,b) (a)=max((a),(b));
#define remin(a,b) (a)=min((a),(b));
#define forn(i,n) for(int (i)=0;(i)<(n);++(i))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define repd(i,a,b) for(int (i)=(a); (i)>=(b);--i)

// [](const int &lhs, const int &rhs) {return lhs > rhs; }
// [](const pii &lhs, const pii &rhs) {return lhs.fi < rhs.fi; }

#define dbg 0

bool is_point_in (int p_x, int p_y, int x_1, int y_1, int x_2, int y_2)
{
  return (p_x >= x_1 && p_x <= x_2 && p_y >= y_1 && p_y <= y_2);
}

bool is_h_segment_inter (int s_x_1, int s_y_1, int s_x_2, int s_y_2, int x_1, int y_1, int x_2, int y_2)
{
  return (s_x_1 < x_1 && s_x_2 > x_2 && s_y_1 > y_1 && s_y_2 < y_2);
}

bool is_w_segment_inter (int s_x_1, int s_y_1, int s_x_2, int s_y_2, int x_1, int y_1, int x_2, int y_2)
{
  return (s_x_1 > x_1 && s_x_2 < x_2 && s_y_1 < y_1 && s_y_2 > y_2);
}

bool intersect_poly (int a_x_1, int a_y_1, int a_x_2, int a_y_2, //< has bigger area
                    int b_x_1, int b_y_1, int b_x_2, int b_y_2, //< has smaller area
                    int &c_x_1, int &c_y_1, int &c_x_2, int &c_y_2)
{
  bool left_down = is_point_in (b_x_1, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);
  bool left_up = is_point_in (b_x_1, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right_up = is_point_in (b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right_down = is_point_in (b_x_2, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);

  if (left_down && left_up && right_up && right_down) // 4 points in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left_up && right_up) // 2 points in
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_up && right_down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_down && left_down) // 2 points in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (left_up && left_down) // 2 points in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left_up) // 1 point in
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_up) // 1 point in
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_down) // 1 point in
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (left_down) // 1 point in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }

  // if (!left_down && !left_up && !right_up && !right_down) // 0 points in
  bool left = is_w_segment_inter (b_x_1, b_y_1, b_x_1, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool up = is_h_segment_inter (b_x_1, b_y_2, b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right = is_w_segment_inter (b_x_2, b_y_1, b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool down = is_h_segment_inter (b_x_1, b_y_1, b_x_2, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);

  if (left && right)
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (up && down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left)
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (right)
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (up)
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }

  return false;
}

void board (int m, int n, ll &w, ll &b)
{
  w = (m % 2 ? (m / 2 + 1) * n : (m / 2) * n);
  b = (m / 2) * n;
}

void subboard (int x_1, int y_1, int x_2, int y_2, ll &w, ll &b)
{
  int m = x_2 + 1 - x_1;
  int n = y_2 + 1 - y_1;
  if (x_1 % 2 == 0 || y_1 % 2 == 0)
    board (m, n, b, w); //< black start
  else
    board (m, n, w, b); //< white start
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

#if dbg
  cout << endl;
  ifstream cin("input.txt");
#endif

  int n, m;
  int x_1_w, y_1_w, x_2_w, y_2_w;
  int x_1_b, y_1_b, x_2_b, y_2_b;
  int x_1_wb, y_1_wb, x_2_wb, y_2_wb;
  ll t, w_res, b_res;
  cin >> t;
  while (t--)
    {
      cin >> n >> m;
      cin >> x_1_w >> y_1_w >> x_2_w >> y_2_w;
      cin >> x_1_b >> y_1_b >> x_2_b >> y_2_b;

      ll w_initial = 0;
      ll b_initial = 0;
      board (m, n, w_initial, b_initial);

      ll w_1 = 0;
      ll b_1 = 0;
      subboard (x_1_w, y_1_w, x_2_w, y_2_w, w_1, b_1);

      ll w_2 = 0;
      ll b_2 = 0;
      subboard (x_1_b, y_1_b, x_2_b, y_2_b, w_2, b_2);

      ll w_3 = 0;
      ll b_3 = 0;
      if ((ll) (x_2_w + 1 - x_1_w) * (ll) (y_2_w + 1 - y_1_w) >= (ll) (x_2_b + 1 - x_1_b) * (ll) (y_2_b + 1 - y_1_b))
        {
          if (intersect_poly (x_1_w, y_1_w, x_2_w, y_2_w, x_1_b, y_1_b, x_2_b, y_2_b, x_1_wb, y_1_wb, x_2_wb, y_2_wb))
            {
              subboard (x_1_wb, y_1_wb, x_2_wb, y_2_wb, w_3, b_3);
            }
        }
      else
        {
          if (intersect_poly (x_1_b, y_1_b, x_2_b, y_2_b, x_1_w, y_1_w, x_2_w, y_2_w, x_1_wb, y_1_wb, x_2_wb, y_2_wb))
            {
              subboard (x_1_wb, y_1_wb, x_2_wb, y_2_wb, w_3, b_3);
            }
        }

      w_res = w_initial + b_1 - w_2 - b_3;
      b_res = b_initial - b_1 + w_2 + b_3;

      cout << w_res << " " << b_res << endl;

    }

#if dbg
  cin.close ();
  cout << endl;
#endif
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpii;
typedef vector<vector<ll>> graph;
typedef long double ld;

#define pb push_back
#define fi first
#define se second
#define sz(x) ((ll)(x.size()))
#define all(t) t.begin(),t.end()
#define in(x,y) ((y).find((x))!=(y).end())
#define remax(a,b) (a)=max((a),(b));
#define remin(a,b) (a)=min((a),(b));
#define forn(i,n) for(ll (i)=0;(i)<(n);++(i))
#define rep(i,a,b) for(ll (i)=(a);(i)<=(b);++i)
#define repd(i,a,b) for(ll (i)=(a); (i)>=(b);--i)

// [](const ll &lhs, const ll &rhs) {return lhs > rhs; }
// [](const pii &lhs, const pii &rhs) {return lhs.fi < rhs.fi; }

#define dbg 0

bool is_poll_in (ll p_x, ll p_y, ll x_1, ll y_1, ll x_2, ll y_2)
{
  return (p_x >= x_1 && p_x <= x_2 && p_y >= y_1 && p_y <= y_2);
}

bool is_h_segment_ller (ll s_x_1, ll s_y_1, ll s_x_2, ll s_y_2, ll x_1, ll y_1, ll x_2, ll y_2)
{
  return (s_x_1 < x_1 && s_x_2 > x_2 && s_y_1 > y_1 && s_y_2 < y_2);
}

bool is_w_segment_ller (ll s_x_1, ll s_y_1, ll s_x_2, ll s_y_2, ll x_1, ll y_1, ll x_2, ll y_2)
{
  return (s_x_1 > x_1 && s_x_2 < x_2 && s_y_1 < y_1 && s_y_2 > y_2);
}

bool llersect_poly (ll a_x_1, ll a_y_1, ll a_x_2, ll a_y_2, //< has bigger area
                    ll b_x_1, ll b_y_1, ll b_x_2, ll b_y_2, //< has smaller area
                    ll &c_x_1, ll &c_y_1, ll &c_x_2, ll &c_y_2)
{
  bool left_down = is_poll_in (b_x_1, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);
  bool left_up = is_poll_in (b_x_1, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right_up = is_poll_in (b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right_down = is_poll_in (b_x_2, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);

  if (left_down && left_up && right_up && right_down) // 4 polls in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left_up && right_up) // 2 polls in
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_up && right_down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_down && left_down) // 2 polls in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (left_up && left_down) // 2 polls in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left_up) // 1 poll in
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_up) // 1 poll in
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (right_down) // 1 poll in
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (left_down) // 1 poll in
    {
      c_x_1 = b_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }

  // if (!left_down && !left_up && !right_up && !right_down) // 0 polls in
  bool left = is_w_segment_ller (b_x_1, b_y_1, b_x_1, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool up = is_h_segment_ller (b_x_1, b_y_2, b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool right = is_w_segment_ller (b_x_2, b_y_1, b_x_2, b_y_2, a_x_1, a_y_1, a_x_2, a_y_2);
  bool down = is_h_segment_ller (b_x_1, b_y_1, b_x_2, b_y_1, a_x_1, a_y_1, a_x_2, a_y_2);

  if (left && right)
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (up && down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (left)
    {
      c_x_1 = b_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (right)
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = b_x_2; c_y_2 = a_y_2;
      return true;
    }
  else if (up)
    {
      c_x_1 = a_x_1; c_y_1 = a_y_1; c_x_2 = a_x_2; c_y_2 = b_y_2;
      return true;
    }
  else if (down)
    {
      c_x_1 = a_x_1; c_y_1 = b_y_1; c_x_2 = a_x_2; c_y_2 = a_y_2;
      return true;
    }

  return false;
}

void board (ll m, ll n, ll &w, ll &b)
{
  w = (m % 2 ? (m / 2 + 1) * n : (m / 2) * n);
  b = (m / 2) * n;
}

void subboard (ll x_1, ll y_1, ll x_2, ll y_2, ll &w, ll &b)
{
  ll m = x_2 + 1 - x_1;
  ll n = y_2 + 1 - y_1;
  if (x_1 % 2 == 0 || y_1 % 2 == 0)
    board (m, n, b, w); //< black start
  else
    board (m, n, w, b); //< white start
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

#if dbg
  cout << endl;
  ifstream cin("input.txt");
#endif

  ll n, m;
  ll x_1_w, y_1_w, x_2_w, y_2_w;
  ll x_1_b, y_1_b, x_2_b, y_2_b;
  ll x_1_wb, y_1_wb, x_2_wb, y_2_wb;
  ll t, w_res, b_res;
  cin >> t;
  while (t--)
    {
      cin >> n >> m;
      cin >> x_1_w >> y_1_w >> x_2_w >> y_2_w;
      cin >> x_1_b >> y_1_b >> x_2_b >> y_2_b;

      ll w_initial = 0;
      ll b_initial = 0;
      board (m, n, w_initial, b_initial);

      ll w_1 = 0;
      ll b_1 = 0;
      subboard (x_1_w, y_1_w, x_2_w, y_2_w, w_1, b_1);

      ll w_2 = 0;
      ll b_2 = 0;
      subboard (x_1_b, y_1_b, x_2_b, y_2_b, w_2, b_2);

      ll w_3 = 0;
      ll b_3 = 0;
      if ((ll) (x_2_w + 1 - x_1_w) * (ll) (y_2_w + 1 - y_1_w) >= (ll) (x_2_b + 1 - x_1_b) * (ll) (y_2_b + 1 - y_1_b))
        {
          if (llersect_poly (x_1_w, y_1_w, x_2_w, y_2_w, x_1_b, y_1_b, x_2_b, y_2_b, x_1_wb, y_1_wb, x_2_wb, y_2_wb))
            {
              subboard (x_1_wb, y_1_wb, x_2_wb, y_2_wb, w_3, b_3);
            }
        }
      else
        {
          if (llersect_poly (x_1_b, y_1_b, x_2_b, y_2_b, x_1_w, y_1_w, x_2_w, y_2_w, x_1_wb, y_1_wb, x_2_wb, y_2_wb))
            {
              subboard (x_1_wb, y_1_wb, x_2_wb, y_2_wb, w_3, b_3);
            }
        }

      w_res = w_initial + b_1 - w_2 - b_3;
      b_res = b_initial - b_1 + w_2 + b_3;

      cout << w_res << " " << b_res << endl;

    }

#if dbg
  cin.close ();
  cout << endl;
#endif
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> graph;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)(x.size()))
#define all(t) t.begin(),t.end()
#define in(x,y) ((y).find((x))!=(y).end())
#define remax(a,b) (a)=max((a),(b));
#define remin(a,b) (a)=min((a),(b));
#define forn(i,n) for(int (i)=0;(i)<(n);++(i))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define repd(i,a,b) for(int (i)=(a); (i)>=(b);--i)

// [](const int &lhs, const int &rhs) {return lhs > rhs; }
// [](const pii &lhs, const pii &rhs) {return lhs.fi < rhs.fi; }

#define dbg 0

void board (ll m, ll n, ll &w, ll &b)
{
  w = (m % 2 ? (m / 2 + 1) * n : (m / 2) * n);
  b = (m / 2) * n;
}

void subboard (int x_1, int y_1, int x_2, int y_2, ll &w, ll &b)
{
  int m = x_2 + 1 - x_1;
  int n = y_2 + 1 - y_1;
  if (x_1 % 2 == 0 || y_1 % 2 == 0)
    board (m, n, b, w); //< black start
  else
    board (m, n, w, b); //< white start
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

#if dbg
  cout << endl;
  ifstream cin("input.txt");
#endif

  int t;
  cin >> t;
  while (t--)
    {
      int n, m;
      int x_1_w, y_1_w, x_2_w, y_2_w;
      int x_1_b, y_1_b, x_2_b, y_2_b;

      cin >> n >> m;
      cin >> x_1_w >> y_1_w >> x_2_w >> y_2_w;
      cin >> x_1_b >> y_1_b >> x_2_b >> y_2_b;

      ll w_0 = 0; ll b_0 = 0;
      subboard (1, 1, m, n, w_0, b_0);

      ll w_1 = 0; ll b_1 = 0;
      subboard (x_1_w, y_1_w, x_2_w, y_2_w, w_1, b_1);

      ll w_2 = 0; ll b_2 = 0;
      subboard (x_1_b, y_1_b, x_2_b, y_2_b, w_2, b_2);

      ll w_3 = 0; ll b_3 = 0;
      subboard (max(x_1_w, x_1_b), max (y_1_b, y_1_w), min (x_2_w, x_2_b), min (y_2_w, y_2_b), w_3, b_3);

      ll w_res = w_0 + b_1 - w_2 - b_3;
      ll b_res = b_0 - b_1 + w_2 + b_3;

      cout << w_res << " " << b_res << endl;
    }

#if dbg
  cin.close ();
  cout << endl;
#endif
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> graph;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)(x.size()))
#define all(t) t.begin(),t.end()
#define in(x,y) ((y).find((x))!=(y).end())
#define remax(a,b) (a)=max((a),(b));
#define remin(a,b) (a)=min((a),(b));
#define forn(i,n) for(int (i)=0;(i)<(n);++(i))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define repd(i,a,b) for(int (i)=(a); (i)>=(b);--i)

// [](const int &lhs, const int &rhs) {return lhs > rhs; }
// [](const pii &lhs, const pii &rhs) {return lhs.fi < rhs.fi; }

#define dbg 0

void board (ll m, ll n, ll &w, ll &b)
{
  if (m % 2 == 0)
    {
      w = b = (m / 2) * n;
    }
  else if (n % 2 == 0)
    {
      w = b = (n / 2) * m;
    }
  else
    {
      w = b = ((m - 1) / 2) * n + (n / 2);
      w += (n % 2 ? 1 : 0);
    }
}

void subboard (int x_1, int y_1, int x_2, int y_2, ll &w, ll &b)
{
  if (x_1 > x_2 || y_1 > y_2)
    {
      w = 0;
      b = 0;
      return;
    }
  int m = x_2 + 1 - x_1;
  int n = y_2 + 1 - y_1;
  if ((ll) (x_1 + y_2) % 2 == 1)
    {
      //< black start
      board (m, n, b, w);
    }
  else
    {
      //< white start
      board (m, n, w, b);
    }
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

#if dbg
  cout << endl;
  ifstream cin("input.txt");
#endif

  int t;
  cin >> t;
  while (t--)
    {
      int n, m;
      int x_1_w, y_1_w, x_2_w, y_2_w;
      int x_1_b, y_1_b, x_2_b, y_2_b;

      cin >> n >> m;
      cin >> x_1_w >> y_1_w >> x_2_w >> y_2_w;
      cin >> x_1_b >> y_1_b >> x_2_b >> y_2_b;

      ll w_0 = 0; ll b_0 = 0;
      subboard (1, 1, m, n, w_0, b_0);

      ll w_1 = 0; ll b_1 = 0;
      subboard (x_1_w, y_1_w, x_2_w, y_2_w, w_1, b_1);

      ll w_2 = 0; ll b_2 = 0;
      subboard (x_1_b, y_1_b, x_2_b, y_2_b, w_2, b_2);

      ll w_3 = 0; ll b_3 = 0;
      subboard (max(x_1_w, x_1_b), max (y_1_b, y_1_w), min (x_2_w, x_2_b), min (y_2_w, y_2_b), w_3, b_3);

      ll w_res = w_0 + b_1 - w_2 - b_3;
      ll b_res = b_0 - b_1 + w_2 + b_3;

      cout << w_res << " " << b_res << endl;
    }

#if dbg
  cin.close ();
  cout << endl;
#endif
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> graph;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)(x.size()))
#define all(t) t.begin(),t.end()
#define in(x,y) ((y).find((x))!=(y).end())
#define remax(a,b) (a)=max((a),(b));
#define remin(a,b) (a)=min((a),(b));
#define forn(i,n) for(int (i)=0;(i)<(n);++(i))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define repd(i,a,b) for(int (i)=(a); (i)>=(b);--i)

// [](const int &lhs, const int &rhs) {return lhs > rhs; }
// [](const pii &lhs, const pii &rhs) {return lhs.fi < rhs.fi; }

#define dbg 0

void board (ll m, ll n, ll &w, ll &b)
{
  if (m % 2 == 0)
    {
      w = b = (m / 2) * n;
    }
  else
    {
      w = b = ((m - 1) / 2) * n + (n / 2);
      w += (n % 2 ? 1 : 0);
    }
}

void subboard (int x_1, int y_1, int x_2, int y_2, ll &w, ll &b)
{
  if (x_1 > x_2 || y_1 > y_2)
    {
      w = 0;
      b = 0;
      return;
    }
  int m = x_2 + 1 - x_1;
  int n = y_2 + 1 - y_1;
  if (x_1 % 2 == 0 || y_1 % 2 == 0)
    {
      //< black start
      board (m, n, b, w);
    }
  else
    {
      //< white start
      board (m, n, w, b);
    }
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

#if dbg
  cout << endl;
  ifstream cin("input.txt");
#endif

  int t;
  cin >> t;
  while (t--)
    {
      int n, m;
      int x_1_w, y_1_w, x_2_w, y_2_w;
      int x_1_b, y_1_b, x_2_b, y_2_b;

      cin >> n >> m;
      cin >> x_1_w >> y_1_w >> x_2_w >> y_2_w;
      cin >> x_1_b >> y_1_b >> x_2_b >> y_2_b;

      ll w_0 = 0; ll b_0 = 0;
      subboard (1, 1, m, n, w_0, b_0);

      ll w_1 = 0; ll b_1 = 0;
      subboard (x_1_w, y_1_w, x_2_w, y_2_w, w_1, b_1);

      ll w_2 = 0; ll b_2 = 0;
      subboard (x_1_b, y_1_b, x_2_b, y_2_b, w_2, b_2);

      ll w_3 = 0; ll b_3 = 0;
      subboard (max(x_1_w, x_1_b), max (y_1_b, y_1_w), min (x_2_w, x_2_b), min (y_2_w, y_2_b), w_3, b_3);

      ll w_res = w_0 + b_1 - w_2 - b_3;
      ll b_res = b_0 - b_1 + w_2 + b_3;

      cout << w_res << " " << b_res << endl;
    }

#if dbg
  cin.close ();
  cout << endl;
#endif
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lld;

#define forn(i,n) for(int i = 0;i<n;i++)
#define forne(i,j,n) for(int i = j;i<n;i++)
const ll mod = 1e9+7;
const ll INF = 1000000001;
const ll N = 1000001;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll A[N],B[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];

int calWhite(int x1, int y1, int x2, int y2){
	int n = (x2-x1+1);
	int m = (y2-y1+1);
	if((x1+y1)%2 == 0) return (n*m+1)/2;
	else return (n*m)/2;
}

int calBlack(int x1, int y1, int x2, int y2){
	int n = (x2-x1+1);
	int m = (y2-y1+1);
	if((x1+y1)%2 == 1) return (n*m+1)/2;
	else return (n*m)/2;
}

void FindPoints(int x1, int y1, int x2, int y2,
				int x3, int y3, int x4, int y4,int tw,int tb)
{

	int white = tw+calBlack(x1, y1, x2, y2)-calWhite(x3, y3, x4, y4);
	int black = tb-calBlack(x1, y1, x2, y2)+calWhite(x3, y3, x4, y4);
	// cout<<white<<" "<<black<<endl;

	// gives bottom-left point
	// of intersection rectangle
	int x5 = max(x1, x3);
	int y5 = max(y1, y3);

	// gives top-right point
	// of intersection rectangle
	int x6 = min(x2, x4);
	int y6 = min(y2, y4);

	// no intersection
	if (x5 > x6 || y5 > y6) {
		// cout << "No intersection";
		cout<<white<<" "<<black<<endl;
		return;
	}

	// cout << "(" << x5 << ", " << y5 << ") ";

	// cout << "(" << x6 << ", " << y6 << ") ";

	// gives top-left point
	// of intersection rectangle
	int x7 = x5;
	int y7 = y6;

	// cout << "(" << x7 << ", " << y7 << ") ";

	// gives bottom-right point
	// of intersection rectangle
	int x8 = x6;
	int y8 = y5;

	// cout << "(" << x8 << ", " << y8 << ") ";

	// cout<<x5<<","<<y5<<" "<<x6<<","<<y6<<" "<<calBlack(x5,y5,x6,y6)<<endl;
	white = white - calBlack(x5,y5,x6,y6);
	black = black + calBlack(x5,y5,x6,y6);
	cout<<white<<" "<<black<<endl;

}

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll t;
cin>>t;
while(t--){
	ll n,m;
	cin>>n>>m;
	ll tw = (n*m+1)/2;
	ll tb = (n*m)/2;
	ll x1 = 0, y1 = 0, x2 = 10, y2 = 8;
	ll x3 = 2, y3 = 3, x4 = 7, y4 = 9;
	cin>>x1>>y1>>x2>>y2;
	cin>>x3>>y3>>x4>>y4;
	// cout<<tw<<" "<<tb<<endl;

	FindPoints(x1, y1, x2, y2, x3, y3, x4, y4,tw,tb);

}

return 0;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lld;

#define forn(i,n) for(int i = 0;i<n;i++)
#define forne(i,j,n) for(int i = j;i<n;i++)
const ll mod = 1e9+7;
const ll INF = 1000000001;
const ll N = 1000001;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll A[N],B[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];

ll calWhite(int x1, int y1, int x2, int y2){
	ll n = (x2-x1+1);
	ll m = (y2-y1+1);
	if((x1+y1)%2 == 0) return (n*m+1)/2;
	else return (n*m)/2;
}

ll calBlack(int x1, int y1, int x2, int y2){
	ll n = (x2-x1+1);
	ll m = (y2-y1+1);
	if((x1+y1)%2 == 1) return (n*m+1)/2;
	else return (n*m)/2;
}

void FindPoints(ll x1, ll y1, ll x2, ll y2,
				ll x3, ll y3, ll x4, ll y4,ll tw,ll tb)
{

	ll white = tw+calBlack(x1, y1, x2, y2)-calWhite(x3, y3, x4, y4);
	ll black = tb-calBlack(x1, y1, x2, y2)+calWhite(x3, y3, x4, y4);
	// cout<<white<<" "<<black<<endl;

	// gives bottom-left point
	// of intersection rectangle
	ll x5 = max(x1, x3);
	ll y5 = max(y1, y3);

	// gives top-right point
	// of intersection rectangle
	ll x6 = min(x2, x4);
	ll y6 = min(y2, y4);

	// no intersection
	if (x5 > x6 || y5 > y6) {
		// cout << "No intersection";
		cout<<white<<" "<<black<<endl;
		return;
	}

	// cout << "(" << x5 << ", " << y5 << ") ";

	// cout << "(" << x6 << ", " << y6 << ") ";

	// gives top-left point
	// of intersection rectangle
	ll x7 = x5;
	ll y7 = y6;

	// cout << "(" << x7 << ", " << y7 << ") ";

	// gives bottom-right point
	// of intersection rectangle
	ll x8 = x6;
	ll y8 = y5;

	// cout << "(" << x8 << ", " << y8 << ") ";

	// cout<<x5<<","<<y5<<" "<<x6<<","<<y6<<" "<<calBlack(x5,y5,x6,y6)<<endl;
	white = white - calBlack(x5,y5,x6,y6);
	black = black + calBlack(x5,y5,x6,y6);
	cout<<white<<" "<<black<<endl;

}

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll t;
cin>>t;
while(t--){
	ll n,m;
	cin>>n>>m;
	ll tw = (n*m+1)/2;
	ll tb = (n*m)/2;
	ll x1 = 0, y1 = 0, x2 = 10, y2 = 8;
	ll x3 = 2, y3 = 3, x4 = 7, y4 = 9;
	cin>>x1>>y1>>x2>>y2;
	cin>>x3>>y3>>x4>>y4;
	// cout<<tw<<" "<<tb<<endl;

	FindPoints(x1, y1, x2, y2, x3, y3, x4, y4,tw,tb);

}

return 0;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lld;

#define forn(i,n) for(int i = 0;i<n;i++)
#define forne(i,j,n) for(int i = j;i<n;i++)
const ll mod = 1e9+7;
const ll INF = 1000000001;
const ll N = 1000001;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
// ll A[N],B[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];

ll calWhite(int x1, int y1, int x2, int y2){
	ll n = (x2-x1+1);
	ll m = (y2-y1+1);
	if((x1+y1)%2 == 0) return (n*m+1)/2;
	else return (n*m)/2;
}

ll calBlack(int x1, int y1, int x2, int y2){
	ll n = (x2-x1+1);
	ll m = (y2-y1+1);
	if((x1+y1)%2 == 1) return (n*m+1)/2;
	else return (n*m)/2;
}

void FindPoints(int x1, int y1, int x2, int y2,
				int x3, int y3, int x4, int y4,int tw,int tb)
{

	ll white = tw+calBlack(x1, y1, x2, y2)-calWhite(x3, y3, x4, y4);
	ll black = tb-calBlack(x1, y1, x2, y2)+calWhite(x3, y3, x4, y4);
	// cout<<white<<" "<<black<<endl;

	// gives bottom-left point
	// of intersection rectangle
	int x5 = max(x1, x3);
	int y5 = max(y1, y3);

	// gives top-right point
	// of intersection rectangle
	int x6 = min(x2, x4);
	int y6 = min(y2, y4);

	// no intersection
	if (x5 > x6 || y5 > y6) {
		// cout << "No intersection";
		cout<<white<<" "<<black<<endl;
		return;
	}

	// cout << "(" << x5 << ", " << y5 << ") ";

	// cout << "(" << x6 << ", " << y6 << ") ";

	// gives top-left point
	// of intersection rectangle
	int x7 = x5;
	int y7 = y6;

	// cout << "(" << x7 << ", " << y7 << ") ";

	// gives bottom-right point
	// of intersection rectangle
	int x8 = x6;
	int y8 = y5;

	// cout << "(" << x8 << ", " << y8 << ") ";

	// cout<<x5<<","<<y5<<" "<<x6<<","<<y6<<" "<<calBlack(x5,y5,x6,y6)<<endl;
	white = white - calBlack(x5,y5,x6,y6);
	black = black + calBlack(x5,y5,x6,y6);
	cout<<white<<" "<<black<<endl;

}

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll t;
cin>>t;
while(t--){
	ll n,m;
	cin>>n>>m;
	ll tw = (n*m+1)/2;
	ll tb = (n*m)/2;
	ll x1 = 0, y1 = 0, x2 = 10, y2 = 8;
	ll x3 = 2, y3 = 3, x4 = 7, y4 = 9;
	cin>>x1>>y1>>x2>>y2;
	cin>>x3>>y3>>x4>>y4;
	// cout<<tw<<" "<<tb<<endl;

	FindPoints(x1, y1, x2, y2, x3, y3, x4, y4,tw,tb);

}

return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<ll> vll;
#define FOR(i,n) for (i = 0; i < n; ++i)
#define FORK(i,k,n) for (i = k; i <= n; ++i)
#define FORR(i,k,n) for (i = k; i >= n; --i)

#define re(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define input(in)    freopen(in,"r",stdin)
#define output(out)  freopen(out,"w",stdout)
#define ALL(a)       a.begin(),a.end()
#define RALL(a)      a.rbegin(),a.rend()
#define LEN(a)       (int)(a.length())

#define FIN(x)       freopen(x,"r",stdin)
#define FOUT(x)      freopen(x,"w",stdout)
#define FCLOSE       {fclose(stdin); fclose(stdout);}

#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define  M           200003
#define INF          10010010
ll w,b;
void lol(ll x11, ll y11,ll x12, ll y12,ll x21, ll y21,ll x22, ll y22)
{
    //cout << x11 << " " << x12 << " " << y11 << " " << y12 << "\n";
    ll area1 = (abs(x11 - x12)+1) *
                (abs(y11 - y12)+1);
                /*
    if(area1==0)
    {
        if(abs(x11 - x12)>0)
            area1=abs(x11 - x12);
        if(abs(y11 - y12))
            area1=abs(y11 - y12);
    }
    */
    if(area1%2==0)
    {
        w+=area1/2;
        b-=area1/2;
    }
    else
    {
        if((x11+y11)%2!=0)
        {
            w+=area1/2+1;
            b-=area1/2+1;
        }
        else
        {
            w+=area1/2;
            b-=area1/2;
        }
    }
 //   cout << area1 << " " << x11 << " "<< y11 << "\n";
   // cout << w << " " << b << "\n";
    // Area of 2nd Rectangle
    ll area2 = (abs(x21 - x22)+1) *(abs(y21 - y22)+1);
//    if(area2==0)
//    {
//        if(abs(x21 - x22)>0)
//            area2=abs(x21 - x22);
//        if(abs(y21 - y22))
//            area2=abs(y21 - y22);
//    }
    if(area2%2==0)
    {
        w-=area2/2;
        b+=area2/2;
    }
    else
    {
        if((x21+y21)%2==0)
        {
            w-=area2/2+1;
            b+=area2/2+1;
        }
        else
        {
            w-=area2/2;
            b+=area2/2;
        }
    }
  //  cout << area2 << " " << x21 << " "<< y21 << "\n";
   // cout << w << " " << b << "\n";
    ll x31,x32,y31,y32;
    x32=min(x12, x22);
    x31=max(x11, x21);
    y32=min(y12, y22);
    y31=max(y11, y21);
    ll areaI = (min(x12, x22) -
                 max(x11, x21)+1) *
                (min(y12, y22) -
                 max(y11, y21)+1);
  //  cout << areaI << " " << x31 << " "<< y31 << "\n";
  //  if(areaI<area2){
  if(x32>=x31 && y32>=y31){
    if(areaI%2==0)
    {
        w-=areaI/2;
        b+=areaI/2;
    }
    else
    {
        if((x31+y31)%2!=0)
        {
          w-=areaI/2+1;
          b+=areaI/2+1;
        }
          else
          {
            w-=areaI/2;
            b+=areaI/2;
          }
    }
  }
 //   }
    cout << w << " " << b << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
int t;
cin >> t;
 while(t--)
 {
  ll x,y,x11,x12,x21,x22,y11,y12,y21,y22;
  cin >> y >> x;
  ll area=x*y;
  if(area%2==0)
  {
      w=area/2;
      b=area/2;
  }
  else
  {
      w=area/2+1;
      b=area/2;
  }
  cin >> y11 >> x11 >> y12 >> x12;
  cin >> y21 >> x21 >> y22 >> x22;
 // cout << w <<" " << b << "\n";
  lol(x11,y11,x12,y12,x21,y21,x22,y22);
 }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<ll> vll;
#define FOR(i,n) for (i = 0; i < n; ++i)
#define FORK(i,k,n) for (i = k; i <= n; ++i)
#define FORR(i,k,n) for (i = k; i >= n; --i)

#define re(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define input(in)    freopen(in,"r",stdin)
#define output(out)  freopen(out,"w",stdout)
#define ALL(a)       a.begin(),a.end()
#define RALL(a)      a.rbegin(),a.rend()
#define LEN(a)       (int)(a.length())

#define FIN(x)       freopen(x,"r",stdin)
#define FOUT(x)      freopen(x,"w",stdout)
#define FCLOSE       {fclose(stdin); fclose(stdout);}

#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define  M           200003
#define INF          10010010
ll w,b;
void lol(int x11, int y11,int x12, int y12,int x21, int y21,int x22, int y22)
{
    //cout << x11 << " " << x12 << " " << y11 << " " << y12 << "\n";
    ll area1 = (abs(x11 - x12)+1) *
                (abs(y11 - y12)+1);
                /*
    if(area1==0)
    {
        if(abs(x11 - x12)>0)
            area1=abs(x11 - x12);
        if(abs(y11 - y12))
            area1=abs(y11 - y12);
    }
    */
    if(area1%2==0)
    {
        w+=area1/2;
        b-=area1/2;
    }
    else
    {
        if((x11+y11)%2!=0)
        {
            w+=area1/2+1;
            b-=area1/2+1;
        }
        else
        {
            w+=area1/2;
            b-=area1/2;
        }
    }
 //   cout << area1 << " " << x11 << " "<< y11 << "\n";
   // cout << w << " " << b << "\n";
    // Area of 2nd Rectangle
    ll area2 = (abs(x21 - x22)+1) *(abs(y21 - y22)+1);
//    if(area2==0)
//    {
//        if(abs(x21 - x22)>0)
//            area2=abs(x21 - x22);
//        if(abs(y21 - y22))
//            area2=abs(y21 - y22);
//    }
    if(area2%2==0)
    {
        w-=area2/2;
        b+=area2/2;
    }
    else
    {
        if((x11+y11)%2==0)
        {
            w-=area2/2+1;
            b+=area2/2+1;
        }
        else
        {
            w-=area2/2;
            b+=area2/2;
        }
    }
  //  cout << area2 << " " << x21 << " "<< y21 << "\n";
   // cout << w << " " << b << "\n";
    int x31,x32,y31,y32;
    x32=max(x12, x22);
    x31=max(x11, x21);
    y32=max(y12, y22);
    y31=max(y11, y21);
    ll areaI = (min(x12, x22) -
                 max(x11, x21)+1) *
                (min(y12, y22) -
                 max(y11, y21)+1);
  //  cout << areaI << " " << x31 << " "<< y31 << "\n";
  //  if(areaI<area2){
    if(areaI%2==0)
    {
        w-=areaI/2;
        b+=areaI/2;
    }
    else
    {
        if((x31+y31)%2!=0)
        {
          w-=areaI/2+1;
          b+=areaI/2+1;
        }
          else
          {
            w-=areaI/2;
            b+=areaI/2;
          }
    }
 //   }
    cout << w << " " << b << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
int t;
cin >> t;
 while(t--)
 {
  int x,y,x11,x12,x21,x22,y11,y12,y21,y22;
  cin >> x >> y;
  ll area=x*y;
  if(area%2==0)
  {
      w=area/2;
      b=area/2;
  }
  else
  {
      w=area/2+1;
      b=area/2;
  }
  cin >> x11 >> y11 >> x12 >> y12;
  cin >> x21 >> y21 >> x22 >> y22;
 // cout << w <<" " << b << "\n";
  lol(x11,y11,x12,y12,x21,y21,x22,y22);
 }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<ll> vll;
#define FOR(i,n) for (i = 0; i < n; ++i)
#define FORK(i,k,n) for (i = k; i <= n; ++i)
#define FORR(i,k,n) for (i = k; i >= n; --i)

#define re(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define input(in)    freopen(in,"r",stdin)
#define output(out)  freopen(out,"w",stdout)
#define ALL(a)       a.begin(),a.end()
#define RALL(a)      a.rbegin(),a.rend()
#define LEN(a)       (int)(a.length())

#define FIN(x)       freopen(x,"r",stdin)
#define FOUT(x)      freopen(x,"w",stdout)
#define FCLOSE       {fclose(stdin); fclose(stdout);}

#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define  M           200003
#define INF          10010010
ll w,b;
void lol(ll x11, ll y11,ll x12, ll y12,ll x21, ll y21,ll x22, ll y22)
{
    //cout << x11 << " " << x12 << " " << y11 << " " << y12 << "\n";
    ll area1 = (abs(x11 - x12)+1) *
                (abs(y11 - y12)+1);
                /*
    if(area1==0)
    {
        if(abs(x11 - x12)>0)
            area1=abs(x11 - x12);
        if(abs(y11 - y12))
            area1=abs(y11 - y12);
    }
    */
    if(area1%2==0)
    {
        w+=area1/2;
        b-=area1/2;
    }
    else
    {
        if((x11+y11)%2!=0)
        {
            w+=area1/2+1;
            b-=area1/2+1;
        }
        else
        {
            w+=area1/2;
            b-=area1/2;
        }
    }
 //   cout << area1 << " " << x11 << " "<< y11 << "\n";
   // cout << w << " " << b << "\n";
    // Area of 2nd Rectangle
    ll area2 = (abs(x21 - x22)+1) *(abs(y21 - y22)+1);
//    if(area2==0)
//    {
//        if(abs(x21 - x22)>0)
//            area2=abs(x21 - x22);
//        if(abs(y21 - y22))
//            area2=abs(y21 - y22);
//    }
    if(area2%2==0)
    {
        w-=area2/2;
        b+=area2/2;
    }
    else
    {
        if((x11+y11)%2==0)
        {
            w-=area2/2+1;
            b+=area2/2+1;
        }
        else
        {
            w-=area2/2;
            b+=area2/2;
        }
    }
  //  cout << area2 << " " << x21 << " "<< y21 << "\n";
   // cout << w << " " << b << "\n";
    ll x31,x32,y31,y32;
    x32=max(x12, x22);
    x31=max(x11, x21);
    y32=max(y12, y22);
    y31=max(y11, y21);
    ll areaI = (min(x12, x22) -
                 max(x11, x21)+1) *
                (min(y12, y22) -
                 max(y11, y21)+1);
  //  cout << areaI << " " << x31 << " "<< y31 << "\n";
  //  if(areaI<area2){
    if(areaI%2==0)
    {
        w-=areaI/2;
        b+=areaI/2;
    }
    else
    {
        if((x31+y31)%2!=0)
        {
          w-=areaI/2+1;
          b+=areaI/2+1;
        }
          else
          {
            w-=areaI/2;
            b+=areaI/2;
          }
    }
 //   }
    cout << w << " " << b << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
int t;
cin >> t;
 while(t--)
 {
  ll x,y,x11,x12,x21,x22,y11,y12,y21,y22;
  cin >> x >> y;
  ll area=x*y;
  if(area%2==0)
  {
      w=area/2;
      b=area/2;
  }
  else
  {
      w=area/2+1;
      b=area/2;
  }
  cin >> x11 >> y11 >> x12 >> y12;
  cin >> x21 >> y21 >> x22 >> y22;
 // cout << w <<" " << b << "\n";
  lol(x11,y11,x12,y12,x21,y21,x22,y22);
 }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<ll> vll;
#define FOR(i,n) for (i = 0; i < n; ++i)
#define FORK(i,k,n) for (i = k; i <= n; ++i)
#define FORR(i,k,n) for (i = k; i >= n; --i)

#define re(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define input(in)    freopen(in,"r",stdin)
#define output(out)  freopen(out,"w",stdout)
#define ALL(a)       a.begin(),a.end()
#define RALL(a)      a.rbegin(),a.rend()
#define LEN(a)       (int)(a.length())

#define FIN(x)       freopen(x,"r",stdin)
#define FOUT(x)      freopen(x,"w",stdout)
#define FCLOSE       {fclose(stdin); fclose(stdout);}

#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define  M           200003
#define INF          10010010
ll w,b;
void lol(ll x11, ll y11,ll x12, ll y12,ll x21, ll y21,ll x22, ll y22)
{
    //cout << x11 << " " << x12 << " " << y11 << " " << y12 << "\n";
    ll area1 = (abs(x11 - x12)+1) *
                (abs(y11 - y12)+1);
                /*
    if(area1==0)
    {
        if(abs(x11 - x12)>0)
            area1=abs(x11 - x12);
        if(abs(y11 - y12))
            area1=abs(y11 - y12);
    }
    */
    if(area1%2==0)
    {
        w+=area1/2;
        b-=area1/2;
    }
    else
    {
        if((x11+y11)%2!=0)
        {
            w+=area1/2+1;
            b-=area1/2+1;
        }
        else
        {
            w+=area1/2;
            b-=area1/2;
        }
    }
 //   cout << area1 << " " << x11 << " "<< y11 << "\n";
   // cout << w << " " << b << "\n";
    // Area of 2nd Rectangle
    ll area2 = (abs(x21 - x22)+1) *(abs(y21 - y22)+1);
//    if(area2==0)
//    {
//        if(abs(x21 - x22)>0)
//            area2=abs(x21 - x22);
//        if(abs(y21 - y22))
//            area2=abs(y21 - y22);
//    }
    if(area2%2==0)
    {
        w-=area2/2;
        b+=area2/2;
    }
    else
    {
        if((x11+y11)%2==0)
        {
            w-=area2/2+1;
            b+=area2/2+1;
        }
        else
        {
            w-=area2/2;
            b+=area2/2;
        }
    }
  //  cout << area2 << " " << x21 << " "<< y21 << "\n";
   // cout << w << " " << b << "\n";
    l x31,x32,y31,y32;
    x32=max(x12, x22);
    x31=max(x11, x21);
    y32=max(y12, y22);
    y31=max(y11, y21);
    ll areaI = (min(x12, x22) -
                 max(x11, x21)+1) *
                (min(y12, y22) -
                 max(y11, y21)+1);
  //  cout << areaI << " " << x31 << " "<< y31 << "\n";
  //  if(areaI<area2){
    if(areaI%2==0)
    {
        w-=areaI/2;
        b+=areaI/2;
    }
    else
    {
        if((x31+y31)%2!=0)
        {
          w-=areaI/2+1;
          b+=areaI/2+1;
        }
          else
          {
            w-=areaI/2;
            b+=areaI/2;
          }
    }
 //   }
    cout << w << " " << b << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
int t;
cin >> t;
 while(t--)
 {
  ll x,y,x11,x12,x21,x22,y11,y12,y21,y22;
  cin >> x >> y;
  ll area=x*y;
  if(area%2==0)
  {
      w=area/2;
      b=area/2;
  }
  else
  {
      w=area/2+1;
      b=area/2;
  }
  cin >> x11 >> y11 >> x12 >> y12;
  cin >> x21 >> y21 >> x22 >> y22;
 // cout << w <<" " << b << "\n";
  lol(x11,y11,x12,y12,x21,y21,x22,y22);
 }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<ll> vll;
#define FOR(i,n) for (i = 0; i < n; ++i)
#define FORK(i,k,n) for (i = k; i <= n; ++i)
#define FORR(i,k,n) for (i = k; i >= n; --i)

#define re(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define input(in)    freopen(in,"r",stdin)
#define output(out)  freopen(out,"w",stdout)
#define ALL(a)       a.begin(),a.end()
#define RALL(a)      a.rbegin(),a.rend()
#define LEN(a)       (int)(a.length())

#define FIN(x)       freopen(x,"r",stdin)
#define FOUT(x)      freopen(x,"w",stdout)
#define FCLOSE       {fclose(stdin); fclose(stdout);}

#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define  M           200003
#define INF          10010010
ll w,b;
void lol(ll x11, ll y11,ll x12, ll y12,ll x21, ll y21,ll x22, ll y22)
{
    //cout << x11 << " " << x12 << " " << y11 << " " << y12 << "\n";
    ll area1 = (abs(x11 - x12)+1) *
                (abs(y11 - y12)+1);
                /*
    if(area1==0)
    {
        if(abs(x11 - x12)>0)
            area1=abs(x11 - x12);
        if(abs(y11 - y12))
            area1=abs(y11 - y12);
    }
    */
    if(area1%2==0)
    {
        w+=area1/2;
        b-=area1/2;
    }
    else
    {
        if((x11+y11)%2!=0)
        {
            w+=area1/2+1;
            b-=area1/2+1;
        }
        else
        {
            w+=area1/2;
            b-=area1/2;
        }
    }
 //   cout << area1 << " " << x11 << " "<< y11 << "\n";
   // cout << w << " " << b << "\n";
    // Area of 2nd Rectangle
    ll area2 = (abs(x21 - x22)+1) *(abs(y21 - y22)+1);
//    if(area2==0)
//    {
//        if(abs(x21 - x22)>0)
//            area2=abs(x21 - x22);
//        if(abs(y21 - y22))
//            area2=abs(y21 - y22);
//    }
    if(area2%2==0)
    {
        w-=area2/2;
        b+=area2/2;
    }
    else
    {
        if((x21+y21)%2==0)
        {
            w-=area2/2+1;
            b+=area2/2+1;
        }
        else
        {
            w-=area2/2;
            b+=area2/2;
        }
    }
  //  cout << area2 << " " << x21 << " "<< y21 << "\n";
   // cout << w << " " << b << "\n";
    ll x31,x32,y31,y32;
    x32=max(x12, x22);
    x31=max(x11, x21);
    y32=max(y12, y22);
    y31=max(y11, y21);
    ll areaI = (min(x12, x22) -
                 max(x11, x21)+1) *
                (min(y12, y22) -
                 max(y11, y21)+1);
  //  cout << areaI << " " << x31 << " "<< y31 << "\n";
  //  if(areaI<area2){
    if(areaI%2==0)
    {
        w-=areaI/2;
        b+=areaI/2;
    }
    else
    {
        if((x31+y31)%2!=0)
        {
          w-=areaI/2+1;
          b+=areaI/2+1;
        }
          else
          {
            w-=areaI/2;
            b+=areaI/2;
          }
    }
 //   }
    cout << w << " " << b << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
int t;
cin >> t;
 while(t--)
 {
  ll x,y,x11,x12,x21,x22,y11,y12,y21,y22;
  cin >> y >> x;
  ll area=x*y;
  if(area%2==0)
  {
      w=area/2;
      b=area/2;
  }
  else
  {
      w=area/2+1;
      b=area/2;
  }
  cin >> y11 >> x11 >> y12 >> x12;
  cin >> y21 >> x21 >> y22 >> x22;
 // cout << w <<" " << b << "\n";
  lol(x11,y11,x12,y12,x21,y21,x22,y22);
 }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<ll> vll;
#define FOR(i,n) for (i = 0; i < n; ++i)
#define FORK(i,k,n) for (i = k; i <= n; ++i)
#define FORR(i,k,n) for (i = k; i >= n; --i)

#define re(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define input(in)    freopen(in,"r",stdin)
#define output(out)  freopen(out,"w",stdout)
#define ALL(a)       a.begin(),a.end()
#define RALL(a)      a.rbegin(),a.rend()
#define LEN(a)       (int)(a.length())

#define FIN(x)       freopen(x,"r",stdin)
#define FOUT(x)      freopen(x,"w",stdout)
#define FCLOSE       {fclose(stdin); fclose(stdout);}

#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define  M           200003
#define INF          10010010
ll w,b;
void lol(ll x11, ll y11,ll x12, ll y12,ll x21, ll y21,ll x22, ll y22)
{
    //cout << x11 << " " << x12 << " " << y11 << " " << y12 << "\n";
    ll area1 = (abs(x11 - x12)+1) *
                (abs(y11 - y12)+1);
                /*
    if(area1==0)
    {
        if(abs(x11 - x12)>0)
            area1=abs(x11 - x12);
        if(abs(y11 - y12))
            area1=abs(y11 - y12);
    }
    */
    if(area1%2==0)
    {
        w+=area1/2;
        b-=area1/2;
    }
    else
    {
        if((x11+y11)%2!=0)
        {
            w+=area1/2+1;
            b-=area1/2+1;
        }
        else
        {
            w+=area1/2;
            b-=area1/2;
        }
    }
 //   cout << area1 << " " << x11 << " "<< y11 << "\n";
   // cout << w << " " << b << "\n";
    // Area of 2nd Rectangle
    ll area2 = (abs(x21 - x22)+1) *(abs(y21 - y22)+1);
//    if(area2==0)
//    {
//        if(abs(x21 - x22)>0)
//            area2=abs(x21 - x22);
//        if(abs(y21 - y22))
//            area2=abs(y21 - y22);
//    }
    if(area2%2==0)
    {
        w-=area2/2;
        b+=area2/2;
    }
    else
    {
        if((x21+y21)%2==0)
        {
            w-=area2/2+1;
            b+=area2/2+1;
        }
        else
        {
            w-=area2/2;
            b+=area2/2;
        }
    }
  //  cout << area2 << " " << x21 << " "<< y21 << "\n";
   // cout << w << " " << b << "\n";
    ll x31,x32,y31,y32;
    x32=max(x12, x22);
    x31=max(x11, x21);
    y32=max(y12, y22);
    y31=max(y11, y21);
    ll areaI = (min(x12, x22) -
                 max(x11, x21)) *
                (min(y12, y22) -
                 max(y11, y21));
  //  cout << areaI << " " << x31 << " "<< y31 << "\n";
  //  if(areaI<area2){
    if(areaI%2==0)
    {
        w-=areaI/2;
        b+=areaI/2;
    }
    else
    {
        if((x31+y31)%2!=0)
        {
          w-=areaI/2+1;
          b+=areaI/2+1;
        }
          else
          {
            w-=areaI/2;
            b+=areaI/2;
          }
    }
 //   }
    cout << w << " " << b << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
int t;
cin >> t;
 while(t--)
 {
  ll x,y,x11,x12,x21,x22,y11,y12,y21,y22;
  cin >> x >> y;
  ll area=x*y;
  if(area%2==0)
  {
      w=area/2;
      b=area/2;
  }
  else
  {
      w=area/2+1;
      b=area/2;
  }
  cin >> x11 >> y11 >> x12 >> y12;
  cin >> x21 >> y21 >> x22 >> y22;
 // cout << w <<" " << b << "\n";
  lol(x11,y11,x12,y12,x21,y21,x22,y22);
 }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<ll> vll;
#define FOR(i,n) for (i = 0; i < n; ++i)
#define FORK(i,k,n) for (i = k; i <= n; ++i)
#define FORR(i,k,n) for (i = k; i >= n; --i)

#define re(a,b)   memset(a,b,sizeof(a))
#define sz(a)      (int)(a.size())
#define MIN(a,b)     (a) = min((a),(b))
#define MAX(a,b)     (a) = max((a),(b))
#define input(in)    freopen(in,"r",stdin)
#define output(out)  freopen(out,"w",stdout)
#define ALL(a)       a.begin(),a.end()
#define RALL(a)      a.rbegin(),a.rend()
#define LEN(a)       (int)(a.length())

#define FIN(x)       freopen(x,"r",stdin)
#define FOUT(x)      freopen(x,"w",stdout)
#define FCLOSE       {fclose(stdin); fclose(stdout);}

#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define  M           200003
#define INF          10010010
ll w,b;
void lol(ll x11, ll y11,ll x12, ll y12,ll x21, ll y21,ll x22, ll y22)
{
    //cout << x11 << " " << x12 << " " << y11 << " " << y12 << "\n";
    ll area1 = (abs(x11 - x12)+1) *
                (abs(y11 - y12)+1);
                /*
    if(area1==0)
    {
        if(abs(x11 - x12)>0)
            area1=abs(x11 - x12);
        if(abs(y11 - y12))
            area1=abs(y11 - y12);
    }
    */
    if(area1%2==0)
    {
        w+=area1/2;
        b-=area1/2;
    }
    else
    {
        if((x11+y11)%2!=0)
        {
            w+=area1/2+1;
            b-=area1/2+1;
        }
        else
        {
            w+=area1/2;
            b-=area1/2;
        }
    }
 //   cout << area1 << " " << x11 << " "<< y11 << "\n";
   // cout << w << " " << b << "\n";
    // Area of 2nd Rectangle
    ll area2 = (abs(x21 - x22)+1) *(abs(y21 - y22)+1);
//    if(area2==0)
//    {
//        if(abs(x21 - x22)>0)
//            area2=abs(x21 - x22);
//        if(abs(y21 - y22))
//            area2=abs(y21 - y22);
//    }
    if(area2%2==0)
    {
        w-=area2/2;
        b+=area2/2;
    }
    else
    {
        if((x21+y21)%2==0)
        {
            w-=area2/2+1;
            b+=area2/2+1;
        }
        else
        {
            w-=area2/2;
            b+=area2/2;
        }
    }
  //  cout << area2 << " " << x21 << " "<< y21 << "\n";
   // cout << w << " " << b << "\n";
    ll x31,x32,y31,y32;
    x32=max(x12, x22);
    x31=max(x11, x21);
    y32=max(y12, y22);
    y31=max(y11, y21);
    ll areaI = (min(x12, x22) -
                 max(x11, x21)+1) *
                (min(y12, y22) -
                 max(y11, y21)+1);
  //  cout << areaI << " " << x31 << " "<< y31 << "\n";
  //  if(areaI<area2){
    if(areaI%2==0)
    {
        w-=areaI/2;
        b+=areaI/2;
    }
    else
    {
        if((x31+y31)%2!=0)
        {
          w-=areaI/2+1;
          b+=areaI/2+1;
        }
          else
          {
            w-=areaI/2;
            b+=areaI/2;
          }
    }
 //   }
    cout << w << " " << b << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(0);cout.tie(0);
int t;
cin >> t;
 while(t--)
 {
  ll x,y,x11,x12,x21,x22,y11,y12,y21,y22;
  cin >> x >> y;
  ll area=x*y;
  if(area%2==0)
  {
      w=area/2;
      b=area/2;
  }
  else
  {
      w=area/2+1;
      b=area/2;
  }
  cin >> x11 >> y11 >> x12 >> y12;
  cin >> x21 >> y21 >> x22 >> y22;
 // cout << w <<" " << b << "\n";
  lol(x11,y11,x12,y12,x21,y21,x22,y22);
 }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define cls(x, val) memset(x, val, sizeof(x))
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
#define inc(i, l, r) for(int i=l; i<=r; i++)
#define y1 deiojd
#define x1 ewh

const int inf = 0x3f3f3f3f;
const int maxn = 1e5+10;

int readint()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

ll n, m;
int x1, x2, x3, x4;
int y1, y2, y3, y4;

pair<ll, ll> cal1(int x1, int y1, int x2, int y2){
    //cout<<"uu "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
    assert(x1<=x2&&y1<=y2);
    ll hang = y2-y1+1;
    ll lie = x2-x1+1;
    ll tot = hang*lie;
    //cout<<"cal1 "<<tot<<" "<<hang<<" "<<lie<<endl;
    if((hang&1)&&(lie&1)){
        if(x1%2==y1%2){

            return mp(tot/2+1, tot/2);
        }
        else{
            return mp(tot/2, tot/2+1);
        }
    }
    else{
        return mp(tot/2, tot/2);
    }
}

void cal(){
    bool jiao = true;
    if(x3>x2||x4<x1||y3>y2||y4<y1) {
        jiao = false;
    }
    int a1, a2, b1, b2;
    a1 = a2 = b1 = b2 = 0;
    if(y3>=y1&&y3<=y2&&x3<x1){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x1, b1 = y3, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x1, b1 = y3, a2 = x2, b2 = y2;
        }
        else if(x4>=x2&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y3, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y3, a2 = x2, b2 = y4;
        }
    }
    if(y3>=y1&&y3<=y2&&x3>=x1&&x3<=x2){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x3, b1 = y3, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x3, b1 = y3, a2 = x2, b2 = y2;
        }
        else if(x4>=x1&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y3, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y3, a2 = x2, b2 = y4;
        }
    }
    if(y3<y1&&x3<x1){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x1, b1 = y1, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x1, b1 = y1, a2 = x2, b2 = y2;
        }
        else if(x4>=x2&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y1, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y1, a2 = x2, b2 = y4;
        }
    }
    if(y3<y1&&x3>=x1&&x3<=x2){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x3, b1 = y1, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x3, b1 = y1, a2 = x2, b2 = y2;
        }
        else if(x4>=x2&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y1, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y1, a2 = x2, b2 = y4;
        }
    }
    //cout<<"in "<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<endl;
    pair<ll, ll> temp = cal1(1, 1, m, n);
    ll white = temp.first, black = temp.second;
    //cout<<"init "<<white<<" "<<black<<endl;
    if(jiao==false){
        //cout<<"fal "<<white<<" "<<black<<endl;
        temp = cal1(x1, y1, x2, y2);
        white += temp.second;
        black -= temp.second;
        temp = cal1(x3, y3, x4, y4);
        white -= temp.first;
        black += temp.first;
        printf("%lld %lld\n", white, black);

    }
    else{
        temp = cal1(x1, y1, x2, y2);
        white += temp.second;
        black -= temp.second;
        //cout<<"1  "<<white<<" "<<black<<endl;
        //cout<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<endl;
        temp = cal1(a1, b1, a2, b2);
        white -= temp.second;
        black += temp.second;
        //cout<<"2  "<<white<<" "<<black<<endl;
        temp = cal1(x3, y3, x4, y4);
        white -= temp.first;
        black += temp.first;
        //cout<<"3  "<<white<<" "<<black<<endl;
        printf("%lld %lld\n", white, black);
        return ;
    }

}

int main()
{
    ios::sync_with_stdio(false);
    int _;
    scanf("%d", &_);

    while(_--){
        scanf("%d%d", &n, &m);
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

        scanf("%d%d%d%d", &x3, &y3, &x4, &y4);
        cal();

    }
    return 0;
}
/*
100
5 5
3 3 4 3
1000000000 1000000000
1 1 500000000 500000000
500000000 500000000 1000000000 1000000000

1000000000 1000000000
1 1 1000000000 1000000000
2384793 1209473 2384794 1209474

*/


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define cls(x, val) memset(x, val, sizeof(x))
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
#define inc(i, l, r) for(int i=l; i<=r; i++)
#define y1 deiojd
#define x1 ewh

const int inf = 0x3f3f3f3f;
const int maxn = 1e5+10;

int readint()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

ll n, m;
int x1, x2, x3, x4;
int y1, y2, y3, y4;

pair<ll, ll> cal1(int x1, int y1, int x2, int y2){

    ll hang = y2-y1+1;
    ll lie = x2-x1+1;
    ll tot = hang*lie;
    //cout<<"cal1 "<<tot<<" "<<hang<<" "<<lie<<endl;
    if((hang&1)&&(lie&1)){
        if(x1%2==y1%2){

            return mp(tot/2+1, tot/2);
        }
        else{
            return mp(tot/2, tot/2+1);
        }
    }
    else{
        return mp(tot/2, tot/2);
    }
}

void cal(){
    bool jiao = true;
    if(x3>x2||x4<x1||y3>y2||y4<y1) {
        jiao = false;
    }
    int a1, a2, b1, b2;
    if(y3>=y1&&y3<=y2&&x3<x1){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x1, b1 = y3, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x1, b1 = y3, a2 = x2, b2 = y2;
        }
        else if(x4>=x2&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y3, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y3, a2 = x2, b2 = y4;
        }
    }
    if(y3>=y1&&y3<=y2&&x3>=x1&&x3<=x2){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x3, b1 = y3, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x3, b1 = y3, a2 = x2, b2 = y2;
        }
        else if(x4>=x1&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y3, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y3, a2 = x2, b2 = y4;
        }
    }
    if(y3<y1&&x3<x1){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x1, b1 = y1, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x1, b1 = y1, a2 = x2, b2 = y2;
        }
        else if(x4>=x2&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y1, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y1, a2 = x2, b2 = y4;
        }
    }
    if(y3<y1&&x3>=x1&&x3<=x2){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x3, b1 = y1, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x3, b1 = y1, a2 = x2, b2 = y2;
        }
        else if(x4>=x2&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y1, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y1, a2 = x2, b2 = y4;
        }
    }
    //cout<<"in "<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<endl;
    pair<ll, ll> temp = cal1(1, 1, m, n);
    ll white = temp.first, black = temp.second;
    //cout<<"init "<<white<<" "<<black<<endl;
    if(jiao==false){
        //cout<<"fal "<<white<<" "<<black<<endl;
        temp = cal1(x1, y1, x2, y2);
        white += temp.second;
        black -= temp.second;
        temp = cal1(x3, y3, x4, y4);
        white -= temp.first;
        black += temp.first;
        printf("%lld %lld\n", white, black);

    }
    else{
        temp = cal1(x1, y1, x2, y2);
        white += temp.second;
        black -= temp.second;
        //cout<<"1  "<<white<<" "<<black<<endl;
        //cout<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<endl;
        temp = cal1(a1, b1, a2, b2);
        white -= temp.second;
        black += temp.second;
        //cout<<"2  "<<white<<" "<<black<<endl;
        temp = cal1(x3, y3, x4, y4);
        white -= temp.first;
        black += temp.first;
        //cout<<"3  "<<white<<" "<<black<<endl;
        printf("%lld %lld\n", white, black);
        return ;
    }

}

int main()
{
    ios::sync_with_stdio(false);
    int _;
    scanf("%d", &_);

    while(_--){
        scanf("%d%d", &n, &m);
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

        scanf("%d%d%d%d", &x3, &y3, &x4, &y4);
        cal();

    }
    return 0;
}
/*
100
5 5
3 3 4 3
1000000000 1000000000
1 1 500000000 500000000
500000000 500000000 1000000000 1000000000

1000000000 1000000000
1 1 1000000000 1000000000
2384793 1209473 2384794 1209474

*/


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define cls(x, val) memset(x, val, sizeof(x))
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
#define inc(i, l, r) for(int i=l; i<=r; i++)
#define y1 deiojd
#define x1 ewh

const int inf = 0x3f3f3f3f;
const int maxn = 1e5+10;

int readint()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

ll n, m;
int x1, x2, x3, x4;
int y1, y2, y3, y4;

pair<ll, ll> cal1(int x1, int y1, int x2, int y2){
    //cout<<"uu "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
    assert(x1<=x2&&y1<=y2);
    ll hang = y2-y1+1;
    ll lie = x2-x1+1;
    ll tot = hang*lie;
    //cout<<"cal1 "<<tot<<" "<<hang<<" "<<lie<<endl;
    if((hang&1)&&(lie&1)){
        if(x1%2==y1%2){

            return mp(tot/2+1, tot/2);
        }
        else{
            return mp(tot/2, tot/2+1);
        }
    }
    else{
        return mp(tot/2, tot/2);
    }
}

void cal(){
    bool jiao = true;
    if(x3>x2||x4<x1||y3>y2||y4<y1) {
        jiao = false;
    }
    int a1, a2, b1, b2;
    a1 = a2 = b1 = b2 = 0;
    if(y3>=y1&&y3<=y2&&x3<x1){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x1, b1 = y3, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x1, b1 = y3, a2 = x2, b2 = y2;
        }
        else if(x4>=x2&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y3, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y3, a2 = x2, b2 = y4;
        }
    }
    if(y3>=y1&&y3<=y2&&x3>=x1&&x3<=x2){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x3, b1 = y3, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x3, b1 = y3, a2 = x2, b2 = y2;
        }
        else if(x4>=x1&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y3, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y3, a2 = x2, b2 = y4;
        }
    }
    if(y3<y1&&x3<x1){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x1, b1 = y1, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x1, b1 = y1, a2 = x2, b2 = y2;
        }
        else if(x4>=x1&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y1, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x1, b1 = y1, a2 = x2, b2 = y4;
        }
    }
    if(y3<y1&&x3>=x1&&x3<=x2){
        if(x4>=x1&&x4<=x2&&y4>y2){
            a1 = x3, b1 = y1, a2 = x4, b2 = y2;
        }
        else if(x4>x2&&y4>y2){
            a1 = x3, b1 = y1, a2 = x2, b2 = y2;
        }
        else if(x4>=x1&&x4<=x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y1, a2 = x4, b2 = y4;
        }
        else if(x4>x2&&y4<=y2&&y4>=y1){
            a1 = x3, b1 = y1, a2 = x2, b2 = y4;
        }
    }
    //cout<<"in "<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<endl;
    pair<ll, ll> temp = cal1(1, 1, m, n);
    ll white = temp.first, black = temp.second;
    //cout<<"init "<<white<<" "<<black<<endl;
    if(jiao==false){
        //cout<<"fal "<<white<<" "<<black<<endl;
        temp = cal1(x1, y1, x2, y2);
        white += temp.second;
        black -= temp.second;
        temp = cal1(x3, y3, x4, y4);
        white -= temp.first;
        black += temp.first;
        printf("%lld %lld\n", white, black);

    }
    else{
        temp = cal1(x1, y1, x2, y2);
        white += temp.second;
        black -= temp.second;
        //cout<<"1  "<<white<<" "<<black<<endl;
        //cout<<a1<<" "<<b1<<" "<<a2<<" "<<b2<<endl;
        temp = cal1(a1, b1, a2, b2);
        white -= temp.second;
        black += temp.second;
        //cout<<"2  "<<white<<" "<<black<<endl;
        temp = cal1(x3, y3, x4, y4);
        white -= temp.first;
        black += temp.first;
        //cout<<"3  "<<white<<" "<<black<<endl;
        printf("%lld %lld\n", white, black);
        return ;
    }

}

int main()
{
    ios::sync_with_stdio(false);
    int _;
    scanf("%d", &_);

    while(_--){
        scanf("%d%d", &n, &m);
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

        scanf("%d%d%d%d", &x3, &y3, &x4, &y4);
        cal();

    }
    return 0;
}
/*
100
5 5
3 3 4 3
1000000000 1000000000
1 1 500000000 500000000
500000000 500000000 1000000000 1000000000

1000000000 1000000000
1 1 1000000000 1000000000
2384793 1209473 2384794 1209474

*/