#include <bits/stdc++.h>

using namespace std;


int main()
{
	int t,xa,ya,xb,yb,yf,xf;
	cin>>t ;
	
	while(t--)
	{
		cin>>xa>>ya;
		cin>>xb>>yb;
		cin>>xf>>yf;
		
		if(xa==xb && xb==xf &&(yf-ya)*(yf-yb)<0)
		{
			cout<< abs(ya-yb)+2<<endl ;
		}
		else if(ya == yb && yb==yf && (xf-xa)*(xf-xb)<0)
		{
			cout << abs(xa-xb)+2<<endl;
		}
		
		else {
			cout << abs(xa-xb)+abs(ya-yb)<<endl;
		}
	}
	return(0);
}