#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i, l, r) for (long long int i = l; i < r; ++i)
#define frr(i, l, r) for (long long int i = r; i >= l; --i)
#define sortarr sort(arr, arr + n)                              //sorts array in asc order
#define sortarr_r sort(arr, arr + n, greater<long long int>())  //sorts array in desc order
#define make_set set<long long int> s                           //Set arranges in asc order
#define make_set_r set<long long int, greater<long long int>> s ////Set arranges in desc order
#define make_vector vector<long long int> v;
#define max_heap priority_queue<int> pq;                                      // max heap
#define min_heap priority_queue<int, vector<int>, greater<int>> pq;           //min heap
#define make_pairVector vector<pair<long long int, long long int>> pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int> hashmap;
#define pb push_back

//transform(s.begin(), s.end(), s.begin(), ::tolower); //to convert a string entirely to lower case

//toupper(s[i]) or tolower(s[i]) // converting a character to upper or lower case

//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())

//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key
//   itr->second = value
//}

// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());

// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());

// cin >> x >> y;
// pairVector.pb(mp(x,y));

// string size = str.size()

// stack <int> s;

// queue <int> gquiz;

// __gcd(m, n)

// ll arr[10e5 + 5];

// char arr[10e5 + 5];

//vec.insert(v.begin(),value)   -> to insert a value in the vector at the begin

// printf ("%.9f\n",x);
// cout << fixed << setprecision(9);

//covert integer to string :  to_string(integer)

// vector<vector<int> > ans( A , vector<int> (A, 0));  : to initialise a vector or vectors of size = A(total number of rows) and each row having A elements equal to 0

//priority_queue <pair<int,string>, vector<pair<int,string>>, greater<pair<int,string>> > minheap;    ----> minheap of pairs

//for(auto it:mp)
//{
//	a = it.first;
// 	b = it.second;
//}


void SieveOfEratosthenes(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (int p = 2; p <= n; p++)
        if (prime[p])
            cout << p << " ";
}


bool sortbysec(const pair<long long int, long long int> &a, const pair<long long int, long long int> &b)
{
    return (a.second < b.second);
}


bool compare(string &s1, string &s2)
{
    return s1.size() < s2.size();
}


int check_key(map<long long int, long long int> m, long long int key)
{
    // Key is not present
    if (m.find(key) == m.end())
        return 0;

    return 1;
}


/* Iterative Function to calculate (x^y)%p in O(log y) */
int powerMod(long long x, unsigned int y, int p)
{
    int res = 1;     // Initialize result
 
    x = x % p; // Update x if it is more than or
                // equal to p
  
    if (x == 0) return 0; // In case x is divisible by p;
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


/* Iterative Function to calculate (x^y) in O(log y) */
int power(int x, int y)
{
     
    // Initialize answer
    int res = 1;
     
    // Check till the number becomes zero
    while (y)
    {
         
        // If y is odd, multiply x with result
        if (y % 2 == 1)
            res = (res * x);
             
        // y = y/2
        y = y >> 1;
         
        // Change x to x^2
        x = (x * x);
    }
    return res;
}


// Function to print the factors of a number
void printDivisors(int n)
{
    // Note that this loop runs till square root
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
                printf("%d ", i);
 
            else // Otherwise print both
                printf("%d %d ", i, n/i);
        }
    }
}


void yes()
{
    cout << "YES" << endl;
}


void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll x1,y1,x2,y2,x3,y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        ll distAB = abs(x1-x2) + abs(y1-y2);

        if(x1 == x2 && x2 == x3)
        {
            if (y3 < max(y1,y2) && y3 > min(y1,y2))
            {
                distAB += 2;
            }
        }
        else if(y1 == y2 && y2 == y3)
        {
            if(x3 < max(x1,x2) && x3 > min(x1,x2))
            {
                distAB += 2;
            }
        }

        cout << distAB << endl;
    }
    return 0;
}
