#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<deque>
#include<queue>
using namespace std;
#define db double
#define ll long long
int T;
struct node{
    ll x,y;
}p[10];
int u[10], u2[10]; ll x[10],y[10],s[10], u3[10];
ll ans;

void c1(ll px, ll py) {
    ll now = 0;
    now += abs(px - x[u2[1]]) + abs(py - y[u2[1]]);
    now += abs(px - x[u2[3]]);
    now += abs(py - y[u2[2]]);
    s[1] = u3[1] * (x[u2[2]] - px);
    s[2] = u3[2] * (y[u2[3]] - py);
    s[3] = u3[3] * (x[u2[4]] - px);
    s[4] = u3[4] * (y[u2[4]] - py);
    sort(s+1, s+5);
    for(int i=1; i<=4; i++) now+=abs(s[i] - s[2]);
    // if (now==4){
    //     printf("%lld %lld\n", px, py);
    //     for(int i=1; i<=4; i++) printf("%d ",u2[i]);
    //     printf("\n");
    //     for(int i=1; i<=4; i++) printf("%lld %lld\n", x[i], y[i]);
    //     printf("\n");
        
    // }

    ans = min(ans, now);
}

int main() {
    scanf("%d",&T);
    for(;T--;) {
        int n = 4;
        ans = 0;
        for(int i=1; i<=n; i++) {
            scanf("%lld %lld",&p[i].x, &p[i].y);
            ans += p[i].x + p[i].y;
            u[i] = i;
        }
        
        for(;1;) {
            for(int i=1; i<=n; i++)
                x[i] = p[u[i]].x, y[i] = p[u[i]].y;
            for(int i=1; i<=n; i++) u2[i] = i, u3[i] = 1;
            c1(x[1], y[1]); c1(x[1], y[2]); c1(x[3], y[1]); c1(x[3], y[2]); 
            u2[1] = 2; u2[2] = 1; u2[3] = 4; u2[4] = 3;
            u3[1] = u3[3] = -1;
            c1(x[2], y[1]); c1(x[2], y[2]); c1(x[4], y[1]); c1(x[4], y[2]);

            u2[1] = 3; u2[2] = 4; u2[3] = 1; u2[4] = 2;
            u3[1] = 1; u3[2] = -1; u3[3] = 1; u3[4] = -1;
            c1(x[1], y[3]); c1(x[1], y[4]); c1(x[3], y[3]); c1(x[3], y[4]);
            u2[1] = 4; u2[2] = 3; u2[3] = 2; u2[4] = 1;
            u3[1] = u3[3] = -1;
            u3[2] = u3[4] = -1;
            c1(x[2], y[3]); c1(x[2], y[4]); c1(x[4], y[3]); c1(x[4], y[4]);
            if (!next_permutation(u+1, u+1+n)) break;
        }
        
        printf("%lld\n", ans);
    }
    return 0;
}