/**
 * author : cuber_coder
 * created : 10/07/2021 20:05:50
 **/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

void Solve() {
    vector<pair<int, int>> a(3);
    for (auto &i : a) cin >> i.first >> i.second;
    set<int> x{a[0].first, a[1].first, a[2].first}, y{a[0].second, a[1].second, a[2].second};
    int add = 0;
    if (x.size() == 1) {
        int mn = min(a[0].second, a[1].second);
        int mx = max(a[0].second, a[1].second);
        if (mn <= a[2].second and a[2].second <= mx) {
            add = 2;
        }
    } else if (y.size() == 1) {
        int mn = min(a[0].first, a[1].first);
        int mx = max(a[0].first, a[1].first);
        if (mn <= a[2].first and a[2].first <= mx) {
            add = 2;
        }
    }
    cout << abs(a[0].first - a[1].first) + abs(a[0].second - a[1].second) + add << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int testcases = 1;
    cin >> testcases;

    for (int i = 1; i <= testcases; i++) {
        Solve();
    }
    return 0;
}