#include <bits/stdc++.h>
using namespace std;
void LSH()
{
    #ifndef ONLINE_JUDGE
        freopen("1455.inp","r",stdin);
        freopen("1455.out","w",stdout);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
long long a[15],s,c[15],b[15],x[505],y[505];
long long f( long long k )
{
    s = 1e18;
    long long tmp = 0;
    for ( int i = 1 ; i <= 4 ; ++i )
        a[i] = i;
    do{
            tmp = 0;
        for ( int i = 1 ; i <= 4 ; ++i )
        {
            b[i] = x[a[i]];
        }
        for ( int i = 1 ; i <= 4 ; ++i )
            c[i] = y[a[i]];
        b[2] -= k;
        b[4] -= k;
        c[3] -= k;
        c[4] -= k;
        sort(b+1,b+5);
        sort(c+1,c+5);
        for ( int i = 1 ; i <= 4 ; ++i )
            tmp += abs(b[i]-b[2]) + abs(c[i] -c[2]);
        s = min(s,tmp);
    }
    while ( next_permutation(a+1,a+5) );
    return s;
}
long long T,n,ans = 0,l,r,mid;
bool check = false,check1 = false,check2 = false;
void solve()
{
    cin>>T;
    while ( T-- )
    {
        for ( int i = 1 ; i <= 4 ; ++i )
            cin>>x[i]>>y[i];
        l = 0;
        ans = 1e18;
        r = 2000000000;
        while ( l <= r )
        {
            mid = l + r >> 1;
            long long lef = f(mid), rig = f(mid+1);
            if ( lef < rig )
            {
                ans = lef;
                r = mid - 1;

            }
            else
            {
                ans = rig;
                l = mid + 1;
            }
        }
        cout<<ans<<'\n';
    }
}
int main()
{
    LSH();
    solve();
}



