                              ////JAI SHREE RAM////
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const long long int INF = (long long)1e15;
const long long int mod = 1e9+7;
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define sd second
#define ft first

//
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    //return (a.sd>=b.sd);
    return abs(a.ft)+abs(a.sd) < abs(b.ft)+abs(b.sd);
}

void solve()
{
    int x1,y1,x2,y2,x3,y3;cin>>x1>>y1>>x2>>y2>>x3>>y3;
    int ans=abs(x2-x1)+abs(y2-y1);
    if(x1==x2 && x2==x3 && ((y3<y2 && y3>y1)||(y3>y2 && y3<y1))) ans+=2;
    else if(y1==y2 && y2==y3 && ((x3<x2&&x3>x1)||(x3>x2 && x3<x1))) ans+=2;
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

