
#include <bits/stdc++.h>
#define takes(x) cin >> x;
#define output(x) cout << x << endl;
#define int long long int
#define VectL vector<long long>
#define ll long long
#define VB vector<bool>
#define debug(x) cout << #x << " " << x << endl;
#define f(i, n) for (ll i = 0; i < n; i++)
#define fe(i, n) for (ll i = 1; i <= n; i++)
#define mod 1000000007

using namespace std;
VectL dp(110, -1);
int sum;
void takeArr(VectL &v, int n)
{
    f(i, n)
    {

        cin >> v[i];
    }
}
void printArr(VectL &v)
{
    f(i, v.size())
            cout
        << v[i] << " ";

    cout << "\n";
}

void print2DArr(vector<VectL> &v)
{
    f(i, v.size())
    {
        f(j, v[i].size())
        {
            cout << v[i][j] << " ";
        }
        cout << "\n";
    }
}

int numberOfDigits(int n)

{

    int f = 0;
    while (n != 0)
    {

        n = n / 10;
        f++;
    }
    return f;
}

vector<int> BFS(vector<VectL> matrix, int n)
{
    vector<int> prev(n, -1);
    vector<bool> visited(n, false);
    queue<int> q;
    q.push(0);
    visited[0] = true;
    while (!q.empty())
    {
        int x = q.front();
        cout << x << endl;
        q.pop();
        f(i, n)
        {
            if (matrix[x][i] == 1)
            {
                if (visited[i] == false)
                {
                    q.push(i);
                    visited[i] = true;
                    prev[i] = x;
                }
            }
        }
    }
    return prev;
}
ll sumArr(VectL &v)
{
    ll ans = 0;
    f(i, v.size())
    {
        ans = ans + v[i];
    }
    return ans;
}
void yesno(int ans)
{
    if (ans)
        cout << "Yes\n";
    else
        cout << "No\n";
}

ll power(ll x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return (temp * temp);
    else
        return (x * temp * temp);
}

void DFS(vector<VectL> &v, VB &visited, int x, int &sum)

{

    visited[x] = true;
    f(i, v[x].size())
    {
        if (visited[v[x][i]] == false)
        {
            sum++;

            DFS(v, visited, v[x][i], sum);
        }
    }
}

void printMap(map<int, int> mp)
{
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        cout << it->first << " " << it->second << endl;
    }
    cout << endl;
}
void solve(vector<int> &length)
{
    int n = length.size();
    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + length[i]; j++)
        {
            dp[j] = min(dp[j], dp[i] + 1);
        }
    }
    printArr(dp);
}

int solve()
{
    int a, b;
    cin >> a >> b;
    int c, d;
    cin >> c >> d;
    int e, f;
    cin >> e >> f;
    int ans = 0;
    if (a == c && c == e)
    {
        if ((f > b && f < d) || (f > d && f < b))
            ans = 2;
    }
    if (b == f && f == d)
    {
        if ((e > a && e < c) || (e > c && e < a))
            ans = 2;
    }
    ans = ans + abs(c - a) + abs(d - b);

    return ans;
}

int32_t main()
{
    int t;
    t = 1;
    cin >> t;

    while (t--)
    {
        cout << solve() << endl;
    }

    return 0;
}
