#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <queue>
using namespace std;
using ll=long long;
#define INT_MAX int(1e9 + 1)
#define INT_MIN int(-(1e9 + 1))
#define MOD int(1e9+7)

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

    int t;
    cin>>t;
    while(t--)
    {
        int a,b,c,d,e,f;

        cin>>a>>b;
        cin>>c>>d;
        cin>>e>>f;

        ll ans = abs(a-c) + abs(b-d);

        if(b==d && d==f && ((e>a&&e<c)||(e>c&&e<a))|| a==c && c==e && ((f>b&&f<d)||(f>d&&f<b)))
        {
            ans += 2;
        }
        cout<<ans<<'\n';
    }

}
