#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair < int, int > pii;
 
#define pb push_back
 
#define khan ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
const int N = 5e2 + 5, mod = 998244353, INF = 1e9 + 7;

const double eps = 100000;

typedef long long ll;

const ll BIG = 1e18;

int x[5], y[5];

pair < int, int > a[5];

ll calc(int d){
    ll ans = 0;
    for(int i = 1; i <= 4; i++){
        x[i] = a[i].first;
    }
    for(int i = 1; i <= 4; i++){
        y[i] = a[i].second;
    }
    x[3] -= d;
    x[4] -= d;
    y[4] -= d;
    y[2] -= d;
    sort(x + 1, x + 5);
    sort(y + 1, y + 5);
    for(int i = 1; i <= 4; i++){
        ans += abs(x[i] - x[2]);
        ans += abs(y[i] - y[2]);
    }
    return ans;
}

void solve(){
    for(int i = 1; i <= 4; i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a + 1, a + 5);
    ll ans = BIG;
    do{
        int low = 0, high = 1e9;
        while(low < high){
            int mid = (low + high) / 2;
            if(calc(mid) < calc(mid + 1)){
                high = mid;
            }
            else{
                low = mid + 1;
            }
        }
        ans = min(ans, calc(low));
    }while(next_permutation(a + 1, a + 5));
    cout << ans << endl;
    return;
}

int main(){
    khan
    int q;
    cin >> q;
    while(q--){
        solve();
    }
}
