#include <bits/stdc++.h>
#include<unordered_set>
using namespace std;
#define ll long long int
#define f1(i,n) for(i=0;i<n;i++)
#define f2(i,a,n) for(i=n-1;i>=a;i--)
#define f3(i,n) for(i=1;i<=n;i++)
#define vl vector<long long int>
#define um unordered_map<ll,ll>
#define om map<ll,ll>
#define us unordered_set<ll>
#define pb push_back
#define mp make_pair
#define sv(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define sa(v,n) sort(v,v+n)
#define ra(v,n) sort(v,v+n,greater<int>())
#define mod 1000000007

ll pw(ll x , ll y)
{
    ll i = 0;
    ll ans = 1;
    for (i = 1; i <= y; ++i)
        ans = (ans * x);
    return ans;
}
ll sti(string s){
	ll i,ans=0;
	f1(i,s.length()){
		ans=ans*10+(s[i]-'0');
	}
	return ans;
}

void solution(){
	ll k{},l{},n=0,m{},x=0,y{},o=0,sum=0,ch=0,c1=0,c2=0,i=0,j=0,ans{},a=1,b=0,c,i1,i2,p1,q1,d;
	ll xa,xb,xf,ya,yb,yf;
    cin>>xa>>ya>>xb>>yb>>xf>>yf;
    ans=abs(xa-xb)+abs(ya-yb);
    if(xa==xb){
        if(ya>yb){
            n=ya;
            ya=yb;
            yb=n;
        }
        if((xa==xf) &&(yf<=yb && yf>=ya)) ans=ans+2;
    }
    else if(ya==yb){
        if(xa>xb){
            n=xa;
            xa=xb;
            xb=n;
        }
        if((xf<=xb && xf>=xa) && ya==yf)ans=ans+2;
    }
    cout<<ans<<"\n";
}



//nobody read comments!
int main() {
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing 1output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1;
    cin>>t;
    while(t--)
    solution();
    return 0;
}
