#include<bits/stdc++.h>
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/(__gcd(a,b))
using namespace std;
//priority_queue <int,vector<int>,less<int> > Q;
ll qpow(ll a,ll x){ll ans=1;while(x>0){if(x&1){ans=(ans*a);}a=(a*a);x/=2;}return ans;}
const double eps = 1e-7;
const ll inf= 0x3f3f3f3f3f3f3f3f;
const int N = 1e5+5;
const int mod = 1e9+7;

void solve(){
	int xa,ya,xb,yb,xf,yf;
	cin >> xa >> ya >> xb >> yb >> xf >> yf;
	if(xa == xb || ya == yb){
	//	cout << xa << ' ' << xb << ' ' << xf<< endl;
		if(xa == xb && xa == xf && yf>min(ya,yb) && yf <max(ya,yb)){
			cout << 2+abs(ya-yb) << endl;
			return;
		}
		if(ya == yb && yf == ya && xf>min(xa,xb) && xf <max(xa,xb)){
			cout << 2+abs(xa-xb) << endl;
			return;
		}
	}
	cout << abs(ya-yb) + abs(xa-xb) << endl;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	solve();
	return 0;
}
