#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBJTkYgPSA5OTk5OTk5OwppbnQgZGlzdFsxMV1bMTFdOwpib29sIHZpc1sxMV1bMTFdOwppbnQgZGlyWzhdWzJdID0ge3stMiwtMX0sezIsLTF9LHstMiwxfSx7MiwxfSx7LTEsLTJ9LHsxLC0yfSx7LTEsMn0sezEsMn19OwojZGVmaW5lIG1wIG1ha2VfcGFpcgp2b2lkIGJmcyhpbnQgeCwgaW50IHkpCnsKCW1lbXNldCh2aXMsIGZhbHNlLCBzaXplb2YodmlzKSk7CglxdWV1ZTxwYWlyPGludCwgaW50PiA+cTsKCXEucHVzaChtcCh4LCB5KSk7CglkaXN0W3hdW3ldID0gMDsKCXdoaWxlKCFxLmVtcHR5KCkpewoJCXBhaXI8aW50LCBpbnQ+IHQgPSBxLmZyb250KCk7CgkJaW50IHUgPSB0LmZpcnN0LC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