#include <bits/stdc++.h>
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
using namespace std;

const int MAX = 2e6+10;
const int mid = 1e6+5;
LL ans;
struct pt
{
    int x,y;
}point[4];

int a[4];

void solve()
{
    pt p1=point[a[0]],p2=point[a[1]],p3=point[a[2]],p4=point[a[3]];
    LL x1=min(p1.x,p3.x),x2=max(p1.x,p3.x),x3=min(p2.x,p4.x),x4=max(p2.x,p4.x);
    LL y1=min(p1.y,p2.y),y2=max(p1.y,p2.y),y3=min(p3.y,p4.y),y4=max(p3.y,p4.y);
    LL costx = x2-x1+x4-x3,costy = y2-y1+y4-y3;
    LL xl = min(abs(x2-x3),abs(x4-x1)), xr = max(abs(x2-x3),abs(x4-x1));
    LL yl= min(abs(y2-y3),abs(y3-y1)), yr = max(abs(y2-y3),abs(y3-y1));
    LL val = max(0ll,max(xl,yl)-min(xr,yr));
    ans = min(ans,costx+costy+2*val);
}


int main()
{
    //freopen("in.txt","r",stdin);
    int Cas = 1;
    scanf("%d",&Cas);
    while(Cas--)
    {
        for (int i = 0;i < 4;i++)
            scanf("%d%d",&point[i].x,&point[i].y);
        for (int i = 0;i < 4;i++)
            a[i] = i;
        ans = 0x3f3f3f3f3f3f3f3f;
        do
        {
            solve();
        }while(next_permutation(a,a+4));
        printf("%lld\n",ans);
    }
    return 0;
}
