def dijkstra(s, n, graph): INF = 10 ** 18 import heapq dist = [INF] * n dist[s] = 0 bef = [0] * n bef[s] = s hq = [(0, s)] heapq.heapify(hq) visit = [False] * n while hq: c, v = heapq.heappop(hq) visit[v] = True if c > dist[v]: continue for to, cost in graph[v]: if visit[to] == False and dist[v] + cost < dist[to]: dist[to] = cost + dist[v] bef[to] = v heapq.heappush(hq, (dist[to], to)) return dist, bef def solve(a, b, c, d): ind = {} i = 0 for v in [0, 1, a, b, c, d]: for u in [0, 1, a, b, c, d]: if u != v: ind[u, v] = i i += 1 graph = [[] for _ in range(i)] for u1, v1 in ind.keys(): i1 = ind[u1, v1] for u2, v2 in ind.keys(): i2 = ind[u2, v2] if u1 <= u2 and v1 <= v2 and i1 != i2 and ((u1 < v1 and u2 < v2) or (u1 > v1 and u2 > v2)): graph[i1].append((i2, abs(u2 - u1) + abs(v2 - v1))) if (u2 == 0 and v1 == v2) or (v2 == 0 and u1 == u2): graph[i1].append((i2, 1)) D, _ = dijkstra(ind[a, b], i, graph) return (D[ind[(c, d)]]) for _ in range(int(input())): a, b, c, d = map(int,input().split()) print(solve(a, b, c, d))