#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

void solve() {
    int a1, a2;
    cin >> a1 >> a2;

    int b1, b2;
    cin >> b1 >> b2;
    int c1, c2;
    cin >> c1 >> c2;

    int ans = abs(a1 - b1) + abs(a2 - b2);
    if (a1 == b1 && b1 == c1 && (min(a2, b2) < c2 && c2 < max(a2, b2))) {
        ans += 2;
    }
    else if (a2 == b2 && b2 == c2 && (min(a1, b1) < c1 && c1 < max(a1, b1))) {
        ans += 2;
    }

    cout << ans << endl;
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}
