import sys, time, random, heapq, math, itertools, copy from collections import deque, Counter, defaultdict #from sortedcontainers import SortedSet, SortedList from bisect import bisect, bisect_left, bisect_right import heapq as hq from functools import cache, cmp_to_key def debug(*x):print('debug:',*x, file=sys.stderr) sys.setrecursionlimit(300000) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 dir = [(0, 1), (0, -1), (1, 0), (-1, 0)] T = ii() for _ in range(T): Sx, Sy, Tx, Ty = mi() if Sx == Sy: print(abs(Sy - Ty)) continue if Sx > Tx: Sx, Sy, Tx, Ty = Tx, Ty, Sx, Sy ans = 0 if Sy < Ty: ans += Ty - Sy Sy = Ty elif Ty < Sy: ans += Sy - Ty Ty = Sy left_s, right_s = (Sx // pow(2, Sy))*pow(2, Sy), (Sx // pow(2, Sy))*pow(2,Sy) + pow(2, Sy) left_t, right_t = (Tx // pow(2, Ty))*pow(2, Ty), (Tx // pow(2, Ty))*pow(2,Ty) + pow(2, Ty) debug(left_s, right_s) debug(left_t, right_t) ans += (left_t - left_s) // pow(2, Sy) print(ans)