#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int t;
  cin>>t;
  while(t--){
    int xa,ya,xb,yb,xf,yf;
    cin>>xa>>ya>>xb>>yb>>xf>>yf;
    
    if(xa==xb && xf==xa && (yf-ya)*(yf-yb)<0) cout<<abs(ya-yb)+2<<endl;
    else if(ya==yb && yf==ya && (xf-xa)*(xf-xb)<0) cout<<abs(xa-xb)+2<<endl;
    else cout<<abs(xa-xb)+abs(ya-yb)<<endl;
    
    
    
    
  }
  
  
    
  return 0;
}