#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long LL;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T;
    int Ax, Ay;
    int Bx, By;
    int Fx, Fy;
    cin >> T;
    while (T--)
    {
        cin >> Ax >> Ay;
        cin >> Bx >> By;
        cin >> Fx >> Fy;

        if ((Ax == Bx && Ax == Fx) && ((Fy > Ay && Fy < By)||(Fy<Ay && Fy>By)))
        {
            cout<<abs(Ax-Bx) + abs(Ay-By) + 2<<"\n";
        }
        else if ((Ay == By && Ay == Fy) && ((Fx > Ax && Fx < Bx)||(Fx<Ax && Fx>Bx)))
        {
            cout<<abs(Ax-Bx) + abs(Ay-By) + 2<<"\n";
        }
        else
        {
            cout<<abs(Ax-Bx) + abs(Ay-By)<<"\n";
        }
    }

    return 0;
}