#include<bits/stdc++.h>
using namespace std;
#define en      '\n'
#define endl    '\n'
#define ll      long long signed
#define pb      push_back
#define append  push_back
#define all(v)  (v).begin(),(v).end()
#define FOR(i,a,b,k) for(int i=a; k>0?i<b:i>b; i+=k)
#define fori(a) for(int i=0; i<a; i++)
#define forj(a) for(int j=0; j<a; j++)
#define fork(a) for(int k=0; k<a; k++)
#define MOD     1000000007
#define MAX     1000010
#define mset(a,s,k) memset(a,k,s*sizeof(a[0]))
#define ff      first
#define ss      second
#define __      <<" "<<
#define _       <<en

ll pow_(ll a,ll e,ll m=MOD){ll r=1;while(e){if(e&1)r=r*a%m;a=a*a%m;e>>=1;}return r;} 
int inv(ll a) {return int(pow_(a,MOD-2,MOD));}int add(ll a, ll b){return (a+b+MOD)%MOD;} int mul(ll a, ll b)
{return (MOD+a*b%MOD)%MOD;}int di(ll a, ll b){return mul(a,inv(b));}ll  ceil(ll a,ll b){return a/b+(a%b!=0);}
template<typename T1,typename T2>ostream&operator<<(ostream&O,pair<T1,T2>a){O<<"( ";O<<a.ff<<", "<<a.ss;O<<" )";return O;}
template<typename T>ostream&operator<<(ostream&O,vector<T>V){O<<"[ ";fori(V.size())O<<V[i]<<(i==V.size()-1?"":", ");O<<" ]";return O;}
template<typename T>ostream&operator<<(ostream&O,set<T>S){O<<"{ ";for(T i:S)O<<i<<", ";O<<" }";return O;}
template<typename T1,typename T2>ostream&operator<<(ostream&O,map<T1,T2>S){O<<"{ ";for(auto i:S)O<<i<<", ";O<<" }";return O;}
template<typename T=int>class print{public:vector<T>V;print(vector<T>v){V=v;cout<<" <"<<V<<"> ";}
print(T*x,int n){fori(n)V.push_back(x[i]);cout<<" <"<<V<<"> ";}friend ostream&operator<<(ostream&O,print p){return O;}};

#define vi vector<int>
#define tp pair<int,int>

array<int64_t,4> X,Y,sq,x,y;
int arr[MAX]; int N;
void reset();

// ll eval(int64_t k){
    
//     // abs(x0-x) + abs(x3-x) + abs(x1-k -x) + abs(x2-k -x);
//     // abs(y3-x) + abs(y2-x) + abs(y0-k -x) + abs(y1-k -x);
//     vector<int> ptx={x[0],x[3], x[1]-(ll)k, x[2]-k};
//     vector<int> pty={y[3],y[2], y[0]-k, y[1]-k};
//     sort(all(ptx));
//     sort(all(pty));
//     ll res=0;
//     fori(4){
//         res+=abs(ptx[i]-ptx[1]);
//         res+=abs(pty[i]-pty[1]);
//     }
//     return res;
// }
const int64_t XY_MAX = int(1e9) + 5;

int solve(){
 
    for (int i = 0; i < 4; i++)
        cin >> X[i] >> Y[i];
 
    array<int64_t, 4> orig_X = X, orig_Y = Y;
    array<int, 4> perm = {0, 1, 2, 3};
    int64_t best = XY_MAX * XY_MAX;
    auto eval = [&](int64_t k) {
        array<int64_t, 4> CX = X, CY = Y;
        CX[1] -= k;
        CX[3] -= k;
        CY[2] -= k;
        CY[3] -= k;
        sort(CX.begin(), CX.end());
        sort(CY.begin(), CY.end());
        int64_t value = 0;
 
        for (int i = 0; i < 4; i++)
            value += abs(CX[i] - CX[1]) + abs(CY[i] - CY[1]);
 
        return value;
    };
    do {
        for (int i = 0; i < 4; i++) {
            X[i] = orig_X[perm[i]];
            Y[i] = orig_Y[perm[i]];
        }
 
        int64_t low = 0, high = 2 * XY_MAX;
 
        while (low < high) {
            int64_t mid = (low + high) / 2;
 
            if (eval(mid) < eval(mid + 1))
                high = mid;
            else
                low = mid + 1;
        }
 
        best = min(best, eval(low));
    } while (next_permutation(perm.begin(), perm.end()));
 
    cout << best << '\n';
    return 0;
}

void reset(){

    
    // Clear Vectors, maps, sets
    // Set default values of arr
}
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    cin>>t;
    while(t--){
        solve();
        // cout<<solve()<<en;
        // cout<<(solve()?"Yes":"No")<<endl;
    }
    return 0;
}

