#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
using namespace std;
const int mod=1e9+7;
template<typename KeyType, typename ValueType> 
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>; 
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  }); 
}
vector<ll>inp_ll(int n)
{
	vector<ll>v(n);
	for(ll &x:v)
	{
		cin>>x;
	}
	return v;
}
vector<int>inp_int(int n)
{
	vector<int>v(n);
	for(int &x:v)
	{
		cin>>x;
	}
	return v;
}
void display_ll(vector<ll>v)
{
	for(auto x:v)
	{
		cout<<x<<" ";
	}
}
void display_int(vector<int>v)
{
	for(auto x:v)
	{
		cout<<x<<" ";
	}
}
ll sum_ll(vector<ll>v)
{
	return accumulate(all(v),0ll);          
}
int sum_int(vector<int>v)
{
	return accumulate(all(v),0);              
}
ll binpow(ll a,ll b)
{
	if(b==0)
	{
		return 1;
	}
	ll res=binpow(a,b/2);
	if(b%2)
	{
		return (res*res*a);
	}
	else
	{
		return (res*res);
	}
}
ll gcd(ll a,ll b)
{
	if(a==0)
	{
		return b;
	}
	return gcd(b%a,a);
}
void solve()
{
	int xa,ya,xb,yb,xf,yf;
	cin>>xa>>ya>>xb>>yb>>xf>>yf;
	int ans=abs(xa-xb)+abs(ya-yb);
	if((xa==xb&&xb==xf))
	{
		if(yf>=min(ya,yb)&&yf<=max(ya,yb))
		{
			ans+=2;
		}
	}
	if((ya==yb&&yb==yf))
	{
		if(xf>=min(xa,xb)&&xf<=max(xa,xb))
		{
			ans+=2;
		}
	}
	cout<<ans;
	return;	
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<"\n";
	}
}

