class Program { static void Main() { int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { long[] vs = Console.ReadLine().Split().Select(_ => long.Parse(_)).ToArray(); long sx = vs[0]; long sy = vs[1]; long tx = vs[2]; long ty = vs[3]; long left = Math.Min(sx, tx); long right = Math.Max(sx, tx); long max_y = Math.Max(sy, ty); if (max_y <= 60) { long ans = long.MaxValue; for (int i_max_y = (int)max_y; i_max_y <= 60; i_max_y++) { long dx = right / (1L << i_max_y) - left / (1L << i_max_y); long dy = Math.Abs(ty - sy); ans = Math.Min(ans, dx + dy + 2 * (i_max_y - (int)max_y)); } Console.WriteLine(ans); } else { long dy = Math.Abs(ty - sy); Console.WriteLine(dy); } } } }