#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <iostream>
#define INF 987654321
#define MOD 1000
#define ZERO 1.0e-10
using namespace std;
typedef long long ll;

int _abs(int x) { return x < 0 ? -x : x; }

int main() 
{
	int t;

	scanf(" %d", &t);
	while (t--)
	{
		int xa, ya, xb, yb, xf, yf;
		int ret;

		scanf(" %d %d", &xa, &ya);
		scanf(" %d %d", &xb, &yb);
		scanf(" %d %d", &xf, &yf);

		ret = _abs(xb - xa) + _abs(yb - ya);
		if ((xa == xb && xb == xf) && ((ya < yf && yf < yb) || (yb < yf && yf < ya)))
			ret += 2;
		else if ((ya == yb && yb == yf) && ((xa < xf && xf < xb) || (xb < xf && xf < xa)))
			ret += 2;

		printf("%d\n", ret);
	}
	return 0;
}
