#include <bits/stdc++.h>
using namespace std;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vppii vector<ppii>
#define vpll vector<pll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define vvpll vector<vector<pll>>
#define vvpii vector<vector<pii>>
#define mii map<int,int>
#define mll map<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define per(i,b,a) for(ll i=(b);i>=(a);i--)
#define LLmin LLONG_MIN
#define LLmax LLONG_MAX

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;

const ll mod = 1e9+7;
const ll N =200020;
const ll inf=1e18;
const ll ninf=-1e18;

ll gcd(ll, ll);
ll modPower(ll, ll, ll);
ll power(ll, ll);
ll modInverse(ll, ll);
// ll fact[N];


ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
ll modPower(ll x, ll y, ll m)
{
	if (y == 0)return 1;
	ll p = modPower(x, y / 2, m) % m;
	p = (p * p) % m;
	return (y % 2 == 0) ? p : (x * p) % m;
}
ll power(ll x, ll y)
{
	if (y == 0)return 1;
	ll p = power(x, y / 2);
	p = (p * p);
	return (y % 2 == 0) ? p : (x * p);
}
ll modInverse(ll a, ll m)
{
	return ((modPower(a, m - 2, m) + mod) % mod);
}

// Function to compute a/b under modlo m
ll modDivide(ll a, ll b, ll m)
{
    a = a % m;
    ll inv = modInverse(b, m);
    if (inv == -1)
       return 0;
    else
       return (inv * a) % m;
}

// ll nCr(ll n,ll r){
//     // just calculate factorial till N before using it.
//     ll ans=modDivide(fact[n],fact[r],mod);
//     ans=modDivide(ans,fact[n-r],mod);
//     return ans;
// }

struct comparepq{
    bool operator()(ppii a,ppii b){
        if(a.ff==b.ff) return a.ss.ff>b.ss.ff;
        return a.ff<b.ff;
    }
};


bool myCompare(pii a,pii b){
     if(a.ff==b.ff) return a.ss<b.ss;  
    return a.ff<b.ff;
}

/*------------------------------------CODE STARTS HERE------------------------------------------------*/

void solve() {
    int xa,ya,xb,yb,xf,yf;
    cin>>xa>>ya>>xb>>yb>>xf>>yf;
    
    if(xa==xb && xb==xf){
        int ans=abs(xa-xb)+abs(ya-yb);
        if(ya>yb) swap(ya,yb);
        if(yf>=ya && yf<=yb) ans+=2;
        cout<<ans<<"\n"; return;
    }
    if(yb==ya && ya==yf){
        int ans=abs(ya-yb)+abs(xa-xb);
        if(xa>xb) swap(xa,xb);
        if(xf>=xa && xf<=xb) ans+=2;
        cout<<ans<<"\n"; return;
    }
    
    
    int ans=abs(xa-xb)+abs(ya-yb);
    cout<<ans<<"\n";
    
	return;
}


int main() {
	fastIO;
    
    
	ll t = 1;
 	cin >> t;
	rep(i, 0, t){
	   // cout<<"Case #"<<i+1<<": ";
	    solve();
	}
	

	return 0;
}