#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e9+7;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tt,xa,ya,xb,yb,xf,yf;
  cin>>tt;
  while(tt--)
  {
    cin>>xa>>ya>>xb>>yb>>xf>>yf;
    if(xa==xb && xa==xf)
    {
      if(min(ya,yb)<yf && yf<max(ya,yb))
        cout<<abs(ya-yb)+2<<endl;
      else
        cout<<abs(ya-yb)<<endl;
    }
    else if(ya==yb && yf==ya)
    {
      if(min(xa,xb)<xf && xf<max(xa,xb))
        cout<<abs(xa-xb)+2<<endl;
      else
        cout<<abs(xa-xb)<<endl;
    }
    else
      cout<<abs(xa-xb)+abs(ya-yb)<<endl;
  }
  return 0;
}

