#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[])
{
    int t, a1, a2, b1, b2, f1, f2;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        cin >> a1 >> a2 >> b1 >> b2 >> f1 >> f2;
        if (a1 == b1 && a1 != f1) // verical case with no hurdle.
        {
            cout << fabs(b2 - a2) << endl;
        }
        else if (a2 == b2 && a2 != f2) // horizontal case with no hurdle
        {
            cout << fabs(b1 - a1) << endl;
        }
        else if (a1 == f1 && f1 == b1&&f2<max(a2,b2)&&f2>min(a2,b2)) //vetical with hurdles.
        {
            cout << (fabs(b2 - a2) + 2) << endl;
        }
        else if (a2 == b2 && a2 == f2&&f1<max(a1,b1)&&f1>min(a1,b1)) // horizontal case with hurdle
        {
            cout << (fabs(b1 - a1) + 2) << endl;
        }
        else
        {
            cout << (fabs(b1 - a1) + fabs(b2 - a2))<<endl;
        }
    }

    return 0;
}
