Problem: You are given n points on a plane. 

Please find the minimum sum of areas of two axis-aligned rectangles, such that each point is contained in at least one of these rectangles.

Note that the chosen rectangles can be degenerate. Rectangle contains all the points that lie inside it or on its boundary.

Input

The first line contains one integer t (1 ≤ t ≤ 2 ⋅ 10^5) — the number of test cases.

The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of points.

The following n lines contain the coordinates of the points x_i and y_i (0 ≤ x_i, y_i ≤ 10^9). It is guaranteed that the points are distinct.

It is guaranteed that the sum of values n over all test cases does not exceed 2⋅10^5.

Output

For each test case print one integer — the minimum sum of areas.

Example

Input


3
2
9 1
1 6
2
8 10
0 7
4
0 0
1 1
9 9
10 10


Output


0
0
2

Note

In the first two test cases the answer consists of 2 degenerate rectangles. In the third test case one of the possible answers consists of two rectangles 1 × 1 with bottom left corners (0,0) and (9,9).

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int t,n,L,R,W1,W2,L1,L2,x[N],y[N],A[N],B[N],C[N],D[N],T[N],p[N],cx[N],cy[N],f1[N],f2[N],f3[N],f4[N]; long long ans,f[N],va[N<<2];
struct node{
	int x,y;
}e[N];
inline bool xmp(node A,node B){
	if(A.x==B.x) return A.y<B.y;
	return A.x<B.x;
}
inline bool ymp(node A,node B){
	return A.y<B.y;
}
inline void solve(){
	int a,b,c,d;
	A[1]=e[1].x,B[1]=e[1].x,C[1]=e[1].y,D[1]=e[1].y;
	for(int i=2;i<=n;i++) A[i]=min(A[i-1],e[i].x),B[i]=max(B[i-1],e[i].x),C[i]=min(C[i-1],e[i].y),D[i]=max(D[i-1],e[i].y);
	a=e[n].x,b=e[n].x,c=e[n].y,d=e[n].y;
	for(int i=n;i>=1;i--){
		a=min(a,e[i].x),b=max(b,e[i].x),c=min(c,e[i].y),d=max(d,e[i].y);
		ans=min(ans,1ll*(b-a)*(d-c)+1ll*(B[i-1]-A[i-1])*(D[i-1]-C[i-1]));
	}
	L1=d-c,L2=b-a;
}
struct Tree{
	vector<pair<int,int> >vt[N<<2]; int lt[N<<2];
	inline void build(int l,int r,int t){
		if(l==r){
			vt[t].push_back(make_pair(x[l],y[l])); return;
		}
		int d=(l+r)>>1; build(l,d,t<<1),build(d+1,r,t<<1|1); int len=0;
		for(int i=r;i>=l;i--){
			while(len>=2){
				int A=cx[len],B=cy[len],C=cx[len-1],D=cy[len-1];
				if(1ll*(A-C)*(D-y[i])>1ll*(x[i]-C)*(D-B)) len--; else break;
			}
			len++,cx[len]=x[i],cy[len]=y[i];
		}
		for(int i=1;i<=len;i++) vt[t].push_back(make_pair(cx[i],cy[i]));
	}
	inline long long getans(int l,int r,int t,int ql,int qr,int A,int B){
		if(ql>qr) return 1e18;
		if(l==ql&&r==qr){
			while(lt[t]+1<vt[t].size()){
				long long X=1ll*A*vt[t][lt[t]].first+1ll*B*vt[t][lt[t]].second;
				long long Y=1ll*A*vt[t][lt[t]+1].first+1ll*B*vt[t][lt[t]+1].second;
				if(X>Y) lt[t]++; else break;
			}
			return 1ll*A*vt[t][lt[t]].first+1ll*B*vt[t][lt[t]].second;
		}
		int d=(l+r)>>1; long long sum=1e18;
		if(ql<=d) sum=min(sum,getans(l,d,t<<1,ql,min(d,qr),A,B));
		if(d+1<=qr) sum=min(sum,getans(d+1,r,t<<1|1,max(d+1,ql),qr,A,B));
		return sum;
	}
	inline void solvex(){
		int A=e[1].x,B=e[1].y,C=e[1].x,D=e[1].y;
		for(int i=1;i<=n;i++)
			A=min(A,e[i].x),B=min(B,e[i].y),C=max(C,e[i].x),D=max(D,e[i].y);
		W1=B,W2=C;
		sort(e+1,e+n+1,xmp),T[n]=e[n].y;
		for(int i=n-1;i>=1;i--) T[i]=min(T[i+1],e[i].y); p[p[0]=1]=1;
		for(int i=2;i<=n;i++){
			if(e[i].y<=e[p[p[0]]].y) continue; p[++p[0]]=i;
		}
		for(int i=1;i<p[p[0]];i++) x[i]=W2-e[p[i+1]].x,y[i]=e[p[i]].y-W1; bool fl=(p[0]>1);
		if(fl) build(1,p[0]-1,1); L=1,R=1;
		for(int i=1;i<n;i++){
			while(R+1<=p[0]&&e[p[R+1]].x<=e[i].x&&e[p[R+1]].y>=T[i+1]) R++;
			while(L<=R&&(e[p[L]].x>e[i].x||e[p[L]].y<T[i+1])) L++;
			if(fl) ans=min(ans,getans(1,p[0]-1,1,L,R-1,D-T[i+1],e[i].x-A));
			if(L<=R){
				ans=min(ans,1ll*(e[i].x-A)*(T[i+1]-B)+1ll*(D-T[i+1])*(C-e[p[L]].x));
				ans=min(ans,1ll*(e[i].x-A)*(e[p[R]].y-B)+1ll*(D-T[i+1])*(C-e[i].x));
			}
			
		}
	}
}T1,T2;
inline void solvea(){
	sort(e+1,e+n+1,xmp);
	for(int i=1;i<=n;i++){
		int a=e[1].x,b=e[1].x,c=e[1].y,d=e[1].y;
		for(int j=1;j<i;j++){
			a=min(a,e[j].x);
			b=max(b,e[j].x);
			c=min(c,e[j].y);
			d=max(d,e[j].y);
		}
		for(int j=n;j>=i;j--){
			ans=min(ans,1ll*(D[n]-C[n])*(e[j].x-e[i].x)+1ll*(b-a)*(d-c));
			a=min(a,e[j].x);
			b=max(b,e[j].x);
			c=min(c,e[j].y);
			d=max(d,e[j].y);
		}
	}
}
inline int getmin(int a,int b){
	if(a==-1||b==-1) return a+b+1; return min(a,b);
}
inline int getmax(int a,int b){
	if(a==-1||b==-1) return a+b+1; return max(a,b);
}
inline void build(int l,int r,int t){
	if(l==r){
		va[t]=f[l]; return;
	}
	int d=(l+r)>>1; build(l,d,t<<1),build(d+1,r,t<<1|1),va[t]=min(va[t<<1],va[t<<1|1]);
}
inline long long getmin(int l,int r,int t,int ql,int qr){
	if(l==ql&&r==qr) return va[t]; int d=(l+r)>>1; long long ans=5e18;
	if(ql<=d) ans=min(ans,getmin(l,d,t<<1,ql,min(d,qr)));
	if(d+1<=qr) ans=min(ans,getmin(d+1,r,t<<1|1,max(d+1,ql),qr)); return ans;
}
inline void solve(int l,int r,int A,int B){
	if(l==r){
		ans=min(ans,1ll*(B-A)*L2); return;
	}
	int d=(l+r)>>1; f1[l-1]=A,f2[l-1]=B,f3[r+1]=A,f4[r+1]=B;
	for(int i=l;i<=r;i++) f1[i]=getmin(f1[i-1],e[i].y),f2[i]=getmax(f2[i-1],e[i].y);
	for(int i=r;i>=l;i--) f3[i]=getmin(f3[i+1],e[i].y),f4[i]=getmax(f4[i+1],e[i].y);
	for(int i=d+1;i<=r;i++) f[i]=1ll*L1*e[i].x;
	build(d+1,r,1);
	for(int i=max(2,l);i<=d;i++){
		int x=d+1,y=min(n-1,r),pos=0;
		while(x<=y){
			int z=(x+y)>>1;
			if(f1[i-1]<=f3[z+1]&&f2[i-1]>=f4[z+1]) pos=z,y=z-1; else x=z+1;
		}
		if(pos==0) continue;
		ans=min(ans,getmin(d+1,r,1,pos,r)-1ll*L1*e[i].x+1ll*(f2[i-1]-f1[i-1])*L2);
	}
	
	for(int i=d+1;i<=r;i++) f[i]=1ll*L1*e[i].x-1ll*f3[i+1]*L2;
	build(d+1,r,1);
	for(int i=max(2,l);i<=d;i++){
		int x=d+1,y=min(n-1,r),pos=0;
		while(x<=y){
			int z=(x+y)>>1;
			if(f1[i-1]>=f3[z+1]) pos=z,x=z+1; else y=z-1;
		}
		if(pos==0) continue;
		int pot=0; x=d+1,y=r;
		while(x<=y){
			int z=(x+y)>>1;
			if(f2[i-1]>=f4[z+1]) pot=z,y=z-1; else x=z+1;
		}
		if(pot==0||pos<pot) continue;
		ans=min(ans,getmin(d+1,r,1,pot,pos)-1ll*L1*e[i].x+1ll*f2[i-1]*L2);
	}
	for(int i=d+1;i<=r;i++) f[i]=1ll*L1*e[i].x+1ll*f4[i+1]*L2;
	build(d+1,r,1);
	for(int i=max(2,l);i<=d;i++){
		int x=d+1,y=min(n-1,r),pos=0;
		while(x<=y){
			int z=(x+y)>>1;
			if(f1[i-1]<=f3[z+1]) pos=z,y=z-1; else x=z+1;
		}
		
		if(pos==0) continue;
		int pot=0; x=d+1,y=r;
		while(x<=y){
			int z=(x+y)>>1;
			if(f2[i-1]<=f4[z+1]) pot=z,x=z+1; else y=z-1;
		}
		if(pot==0||pos>pot) continue;
		ans=min(ans,getmin(d+1,r,1,pos,pot)-1ll*L1*e[i].x-1ll*f1[i-1]*L2);
	}
	for(int i=d+1;i<=r;i++) f[i]=1ll*L1*e[i].x+1ll*(f4[i+1]-f3[i+1])*L2;
	build(d+1,r,1);
	for(int i=max(2,l);i<=d;i++){
		int x=d+1,y=min(n-1,r),pos=0;
		while(x<=y){
			int z=(x+y)>>1;
			if(f1[i-1]>=f3[z+1]&&f2[i-1]<=f4[z+1]) pos=z,x=z+1; else y=z-1;
		}
		if(pos==0) continue;
		ans=min(ans,getmin(d+1,r,1,d+1,pos)-1ll*L1*e[i].x);
	}
	int A1=f3[d+1],B1=f4[d+1],C1=f1[d],D1=f2[d];
	solve(l,d,A1,B1),solve(d+1,r,C1,D1);
}
int main(){
	cin>>t;
	while(t--){
		scanf("%d",&n),ans=1e18; int s=0;
		for(int i=1;i<=n;i++) scanf("%d%d",&e[i].x,&e[i].y),s=max(s,e[i].y);
		sort(e+1,e+n+1,xmp),solve();
		sort(e+1,e+n+1,ymp),solve();
		for(int i=1;i<=4*n;i++) T1.vt[i].resize(0),T1.lt[i]=0,T2.vt[i].resize(0),T2.lt[i]=0;
		sort(e+1,e+n+1,xmp),solve(1,n,-1,-1);
		T1.solvex();
		for(int i=1;i<=n;i++) e[i].y=s-e[i].y;
		T2.solvex();
		printf("%lld\n",ans);
	}
}