#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(0);cin.tie(0)
int Order[10];
ll x[10],y[10];
struct P
{
    ll x,y;
}a[10];
ll solve()
{
    //cout<<"*"<<endl;
    for(int i=0;i<4;i++){
        a[i+1].x=x[Order[i]];
        a[i+1].y=y[Order[i]];
    }
    ll l1=min(a[1].x,a[2].x),r1=max(a[1].x,a[2].x);
    ll l2=min(a[3].x,a[4].x),r2=max(a[3].x,a[4].x);
    ll len1=max(0ll,max(l2-r1,l1-r2)),len2=max(r1-l2,r2-l1);
    //cout<<len1<<' '<<len2<<endl;
    l1=min(a[1].y,a[3].y),r1=max(a[1].y,a[3].y);
    l2=min(a[2].y,a[4].y),r2=max(a[2].y,a[4].y);
    ll len3=max(0ll,max(l2-r1,l1-r2)),len4=max(r1-l2,r2-l1);
    //cout<<len3<<' '<<len4<<endl;
    ll ans=abs(a[1].x-a[2].x)+abs(a[3].x-a[4].x)+abs(a[1].y-a[3].y)+abs(a[2].y-a[4].y);
    ll res=max(0ll,max(len1-len4,len3-len2));
    //cout<<ans<<' '<<res<<endl;
    ans+=2*res;
    return ans;
}
int main()
{
    io;
    int T;
    cin>>T;
    while(T--){
        for(int i=1;i<=4;i++){
            cin>>x[i]>>y[i];
        }
        for(int i=0;i<4;i++){
            Order[i]=i+1;
        }
        ll ans=-1;
        do{
            if(ans<0) ans=solve();
            else ans=min(ans,solve());
            //cout<<ans<<endl;
        }while(next_permutation(Order,Order+4));
        printf("%lld\n",ans);
    }
}