#include <bits/stdc++.h>
using namespace std;
const int INF = 9999999;
int dist[11][11];
bool vis[11][11];
int dir[8][2] = {{-2,-1},{2,-1},{-2,1},{2,1},{-1,-2},{1,-2},{-1,2},{1,2}};
#define mp make_pair
void bfs(int x, int y)
{
	memset(vis, false, sizeof(vis));
	queue<pair<int, int> >q;
	q.push(mp(x, y));
	dist[x][y] = 0;
	while(!q.empty()){
		pair<int, int> t = q.front();
		int u = t.first, v = t.second;
		q.pop();
		if (vis[u][v]) continue;
		vis[u][v] = true;
		for(int i = 0; i<8; i++){
			int xx = u + dir[i][0];
			int yy = v + dir[i][1];
			if (xx>0 && xx < 11 && yy>0 && yy<11){
				dist[xx][yy] = min(dist[xx][yy], dist[u][v]+3);
				q.push(mp(xx, yy));
			}
		}
	}
}

int main()
{
	int t;
	cin >> t;
	while (t--){
		int x,y,r,s;
		for (int i = 0; i<11; i++)
			for (int j = 0; j<11; j++)
				dist[i][j] = INF;
		cin >> x >> y >> r >> s;
		++x, ++y, ++r, ++s;
		bfs(x, y);
		cout << dist[r][s] << endl;
	}
	return 0;
}