/*
This is code of SuperJ6 for Codeforces.
Don't copy my code during f*kin' contests.

2.71828182845904523536
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <tuple>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<ll, ll>
#define f first
#define s second

const int n = 4;
ll x[n], y[n], it[n];

pi sol(ll a, ll b, ll c, ll d){
	return {
		max({0ll, min(a, b) - max(c, d), min(c, d) - max(a, b)}),
		max({0ll, max(a, b) - min(c, d), max(c, d) - min(a, b)})
	};
}

void answer(){
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
		it[i] = i;
	}
	
	ll ret = 0x3f3f3f3f3f3f3f3f;
	do{
		ll a, b, c, d;
		tie(a, b) = sol(x[it[0]], x[it[1]], x[it[2]], x[it[3]]);
		tie(c, d) = sol(y[it[0]], y[it[2]], y[it[1]], y[it[3]]);
		
		ret = min(ret, 
			abs(x[it[0]] - x[it[1]]) + abs(x[it[2]] - x[it[3]]) +
			abs(y[it[0]] - y[it[2]]) + abs(y[it[1]] - y[it[3]]) +
			2 * max({0ll, a - d, c - b})
		);
	}while(next_permutation(it, it + n));
	
	cout << ret << endl;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	cin >> t;
	
	for(int i = 0; i < t; i++) answer();

	return 0;
}