#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define ll long long
int main()
{ 
 int test_cases;
 cin>>test_cases;

int x1,y1,x2,y2,x3,y3;
while(test_cases--){
cin>>x1>>y1>>x2>>y2>>x3>>y3;
int count;
if(x1==x2&&x2==x3&& (y3>min(y1,y2)&&y3<max(y1,y2)))
 count = abs(y2-y1) + 2;

else if(y1==y2&&y2==y3&&(x3>min(x1,x2)&&x3<max(x1,x2)))  count = abs(x2-x1) + 2;
else count = abs(x2-x1)+abs(y2-y1);
cout<<count<<endl;
}
 
 
 
 
}


     
