#include <bits/stdc++.h>
#include<string>
#define M 10000000000007
using namespace std;
typedef long long int ll;
int gcd(int a,int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int modpow(int x,int n)
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=((result%M) * (x%M))%M;
        x=((x%M)*(x%M))%M;
        n=n/2;
    }
    return result;
}
int lcm(int a,int b)
{
    return (a*b)/(gcd(a,b));
}
bool isprime(int n)
{
    if(n<2)
        return false;
    for(int i=2; i<=sqrt(n); i++)
        if(n%i==0)
            return false;
    return true;
}
int ctoi(char c)
{
    return c-48;
}
bool visited[1000000] {false};
void add_edge(vector<int> v[],int x,int y)
{
    v[x].push_back(y);
    v[y].push_back(x);
}
void dfs(vector<int> v[],int e)
{
    visited[e] = true;
    for(int i=0; i<v[e].size(); i++)
    {
        if(!visited[v[e][i]])
        {
            dfs(v,v[e][i]);
        }
    }
}
int func(int n)
{
    if(isprime(n))
    {
        return 2*n;
    }
    else
    {
        int idx = 0;
        for(int i=2; i<=n; i++)
        {
            if(n%i==0)
            {
                idx = i;
                break;
            }
        }
        return (idx+n);
    }
}
int maxSubArraySum(ll a[], ll size)
{
    int max_so_far = INT_MIN, max_ending_here = 0,l=0;

    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
        {
            max_so_far = max_ending_here;
            l++;
        }


        if (max_ending_here < 0)
        {
            max_ending_here = 0;

        }

    }
    if(l==size)max_so_far=INT_MAX;
    return max_so_far;
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    ll a1,b1,a2,b2,a3,b3;
		cin>>a1>>b1>>a2>>b2>>a3>>b3;
		ll ans=abs(a1-a2)+abs(b1-b2);
		if(a1==a2 && a1==a3 )
        {
            if((b3>b1 && b3<b2) || (b3>b2 && b3<b1))ans+=2;
        }
        if(b1==b2 && b1==b3 )
        {
            if((a3>a1 && a3<a2) || (a3>a2 && a3<a1))ans+=2;
        }
		cout<<ans<<endl;



	}
	return 0;
}
