#include<bits/stdc++.h>
using namespace std;
int T;
int main() {
	cin >> T;
	while(T--) {
		int xA, yA, xB, yB, xF, yF;
		cin >> xA >> yA >> xB >> yB >> xF >> yF;
		if (xA == xB) {
			if (xF == xA && ((yF > yA && yF < yB) || (yF < yA && yF > yB))) cout << abs(yB - yA) + 2 << "\n";
			else cout << abs(yB - yA) << "\n";
		}
		else if (yA == yB) {
			if (yF == yA && ((xA < xF && xF < xB) || (xA > xF && xF > xB))) cout << abs(xB - xA) + 2 << "\n";
			else cout << abs(xB - xA) << "\n";
		}
		else cout << abs(xB - xA) + abs(yB - yA) <<  "\n";
	}
	return 0;
}
