
//#include "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/dsu>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long int
#define endl "\n"
#define MOD 1000000007
#define mod 1000000007
#define M 1000000007
#define pb push_back
#define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mx 1000005
#define fiint(a,b) memset(a,b,sizeof(a))
#define bitcount __builtin_popcount
#define fori(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cout<<x<<endl;
#define cases(t) int t; cin>>t; while(t--)
#define inf1 INT_MAX
#define all(a) a.begin(),a.end()
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<int,int>
#define pint pair<int,int>
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mp make_pair
#define sz(x) (int)x.size()
#define PI    3.14159265359

//const long long INF=1e18;

bool chmin(int& a, int b){ if(a > b){ a = b; return 1; } return 0; }

 
int factorial[10000001]={0};
 
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


int powerFunction(int x,int y){
    int res = 1;
    // int p = mod;
    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x) ;
    }
    return res;
}

void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
    factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
 
int nCr(int n, int r)
{
    if(r < 0 || r > n){
        return 0;
    }
    int temp = factorial[n];
    temp *= (powerFunction(factorial[r], MOD-2)%MOD);
    temp %= MOD;
    temp *= (powerFunction(factorial[n-r], MOD-2)%MOD);
    temp %= MOD;
    return temp;
}





signed main()
{
    cases(t){
        pair<int,int> a , b , f;
        cin >> a.ff >> a.ss >> b.ff >> b.ss >> f.ff>> f.ss;
        if( (a.ff == b.ff && b.ff == f.ff && min(a.ss , b.ss) < f.ss  && max(a.ss,b.ss) > f.ss ) || (a.ss == b.ss && b.ss == f.ss &&min(a.ff , b.ff) < f.ff  && max(a.ff,b.ff) > f.ff ))
            cout <<abs(a.ff - b.ff) + abs(a.ss - b.ss) + 2 << endl;
        else cout <<abs(a.ff - b.ff) + abs(a.ss - b.ss)<<endl;
    }
}
 

 


