#include<iostream>
using namespace std;
const int maxn=1e5;
int a[maxn];
int main(){
	int t,xA,yA,xF,yF,xB,yB;
	cin>>t;
	while(t--){
		cin>>xA>>yA>>xB>>yB>>xF>>yF;
		if(xA==xB&&xA==xF&&((yF<yA&&yF>yB)||(yF<yB&&yF>yA)))
			cout<<abs(xA-xB)+abs(yA-yB)+2<<endl;
		else if(yA==yB&&yA==yF&&((xF<xA&&xF>xB)||(xF<xB&&xF>xA)))
			cout<<abs(xA-xB)+abs(yA-yB)+2<<endl;
		else	
			cout<<abs(xA-xB)+abs(yA-yB)<<endl;			
	}
}