#include <bits/stdc++.h>
 
using namespace std;
 
#define all(a) (a).begin(), (a).end()
#define int long long

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

    int t;
    cin >> t;
    while(t--) {
        vector<int> x(3), y(3);
        for (int i = 0; i < 3; i++)
            cin >> x[i] >> y[i];

        auto dist = [&](int x1, int y1, int x2, int y2) {
            return abs(x1 - x2) + abs(y1 - y2);
        };

        if (dist(x[0], y[0], x[1], y[1]) != max(abs(x[0] - x[1]), abs(y[0] - y[1]))) {
            cout << dist(x[0], y[0], x[1], y[1]) << '\n';
        }
        else if (dist(x[0], y[0], x[1], y[1]) != dist(x[0], y[0], x[2], y[2]) + dist(x[2], y[2], x[1], y[1])){
            cout << dist(x[0], y[0], x[1], y[1]) << '\n';
        }
        else {
            cout << dist(x[0], y[0], x[1], y[1]) + 2 << '\n';
        }
    }
}
