#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

void solve() {
	int xa, xb, xf, ya, yb, yf;
	cin >> xa >> ya;
	cin >> xb >> yb;
	cin >> xf >> yf;
	int arr_x[3] = { xa, xb, xf };
	sort(arr_x, arr_x + 3);
	int arr_y[3] = { ya, yb, yf };
	sort(arr_y, arr_y + 3);
	if ((arr_x[0] == arr_x[2] && arr_y[1] == yf) || (arr_y[0] == arr_y[2] && arr_x[1] == xf)) {
		cout << abs(xa - xb) + abs(ya - yb) + 2 << '\n';
	}
	else if (xa == xb) {
		cout << abs(ya - yb) << '\n';
	}
	else if (ya == yb) {
		cout << abs(xa - xb) << '\n';
	} else {
		cout << abs(xa - xb) + abs(ya - yb) << '\n';
	}
}
int main()
{
	setlocale(0, "");
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
}