T = int(input()) for _ in range(T): sx, sy, tx, ty = map(int,input().split()) y = max(sy,ty) ans = abs(sx-tx) + abs(sy-ty) while True: tmp = abs(y-ty) + abs(y-sy) + abs((tx >> y) - (sx >> y)) if ans > tmp: ans = tmp; else: break; print(ans)