#include <bits/stdc++.h>
#define forr(i,a,b) for(int i=(a);i<(b);i++)
#define forn(i,n) forr(i,0,n)
#define dforn(i,n) for(int i=n-1;i>=0;i--)
#define forall(it,v) for(auto it=v.begin();it!=v.end();it++)
#define sz(c) ((int)c.size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fst first
#define snd second

#ifdef ANARAP
#else
#endif

using namespace std;

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

struct pto{
	ll x,y;
};

pto v[4];
ii mult[4][3] = {{{1,0},{0,-1},{1,-1}},
	{{-1,0},{0,-1},{-1,-1}},
	{{-1,0},{0,1},{-1,1}},
	{{1,0},{0,1},{1,1}}};
	
ii others[3], dest[3];

ll f(int side)
{
	ll ret = 1e18;
	ll l=1e18,r=1e18,u=1e18,d=1e18,aux=0;
	forn(j,4)
	{
		forn(k,3) dest[k] = mp(v[0].x+side*mult[j][k].fst, v[0].y+side*mult[j][k].snd);
		forn(_,6)
		{
			l=1e18,r=1e18,u=1e18,d=1e18,aux=0;
			forn(k,3)
			{
				l = min(l, max(0LL, others[k].fst - dest[k].fst));
				r = min(r, max(0LL, dest[k].fst - others[k].fst));
				d = min(d, max(0LL, others[k].snd - dest[k].snd));
				u = min(u, max(0LL, dest[k].snd - others[k].snd));
				aux += abs(others[k].fst - dest[k].fst);
				aux += abs(others[k].snd - dest[k].snd);
			}
			aux -= 2*l+2*r+2*u+2*d;
			ret = min(ret, aux);
			next_permutation(others, others+3);
		}
	}
	return ret;
}

int main()
{
	#ifdef ANARAP
		freopen("input.in", "r", stdin);
		//freopen("output.out", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin >> t;
	forn(T,t)
	{
		
		forn(i,4) cin >> v[i].x >> v[i].y;
		forr(i,1,4) others[i-1] = mp(v[i].x, v[i].y);
		int L = 0, R = 1e9+10, M;
		while(L < R)
		{
			M = (L+R)/2;
			if(f(M) > f(M+1)) L = M+1;
			else R = M;
		}
		cout << f(L) << '\n';
	}
	return 0;
}
