#include <iostream>
using namespace std;
#define ll long long

int main()
{
    ll tc;
    cin >> tc;
    while (tc--)
    {
        ll xa, ya, xb, yb, xf, yf, ans = 0;
        cin >> xa >> ya >> xb >> yb >> xf >> yf;
        ans += std::abs(xa - xb);
        ans += std::abs(ya - yb);
        if (xa == xb and xa == xf)
        {
            if (ya < yb)
            {
                if (yf > ya and yf < yb)
                {
                    ans += 2;
                }
            }
            else
            {

                if (yf < ya and yf > yb)
                {
                    ans += 2;
                }
            }
        }
        else if (ya == yb and ya == yf)
        {
            if (xa < xb)
            {
                if (xf > xa and xf < xb)
                {
                    ans += 2;
                }
            }
            else
            {

                if (xf < xa and xf > xb)
                {
                    ans += 2;
                }
            }
        }
        cout << ans << '\n';
    }
    return 0;
}