#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define MOD 1000000007
#define endl '\n'

void run()
{
	int xa, ya, xb, yb, xf, yf;
	cin >> xa >> ya >> xb >> yb >> xf >> yf;

	if (xa == xb && ya == yb)
	{
		cout << 0 << endl;
		return;
	}

	int ans = abs(xa - xb) + abs(ya - yb);

	if (xa == xb && xa == xf && ((ya < yf && yf < yb) || (yb < yf && yf < ya)))
		ans += 2;
	if (ya == yb && ya == yf && ((xa < xf && xf < xb) || (xb < xf && xf < xa)))
		ans += 2;

	cout << ans << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tichnas;
	cin >> tichnas;
	while (tichnas--)
		run();
	return 0;
}