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

typedef long long ll;
typedef pair<ll,ll> pa;

#define fst first
#define snd second
#define pb push_back
#define lld I64d

const int maxn=200005,maxm=512;
const double pi=acos(-1.0);
const ll mod=1000000007;
const double eps=1e-8;

int id[4];
ll a[2][10],tp[2][10];

ll b[2][10];

ll cal(ll x)
{
	for(int i=0;i<4;++i) for(int j=0;j<2;++j) tp[j][i]=b[j][i];
	tp[0][1]-=x;tp[0][2]-=x;tp[1][2]-=x;tp[1][3]-=x;
	sort(tp[0],tp[0]+4);
	sort(tp[1],tp[1]+4);
	ll ans=0;
	for(int i=0;i<2;++i)
	{
		for(int j=0;j<4;++j)
		{
			ans+=tp[i][j]*(j<2?-1:1);
		}
	}
	return ans;
}


ll cal2()
{
	ll lb=0,ub=mod*8;
	ll ans=cal(0);ans=min(ans,cal(ub));
	while(ub-lb>2)
	{
		ll m1=lb+(ub-lb)/3,m2=ub-(ub-lb)/3;
		ll t1=cal(m1),t2=cal(m2);
		ans=min(ans,min(t1,t2));
		if(t1>t2) lb=m1;
		else ub=m2;
	}
	return ans;
}

ll ans;


void solve()
{
	ans=mod*mod;
	for(int i=0;i<4;++i)
	{
		id[i]=i;
		scanf("%lld %lld",&a[0][i],&a[1][i]);
	}
	do
	{
		for(int i=0;i<4;++i)
		{
			for(int j=0;j<2;++j)
			{
				b[j][i]=a[j][id[i]];
			}
		}
		ans=min(ans,cal2());
	}while(next_permutation(id,id+4));
	printf("%lld\n",ans);
}


int main()
{
	int T;
	scanf("%d",&T);
	for(int ca=1;ca<=T;++ca)
	{
		solve();
	}
	return 0;
}

