def f(a, b)
  result = 0
  unless a == b
    result += 1 unless a % 2 == 0
    result += 1 unless b % 2 == 0
    a = (a + 1) / 2
    b = b / 2 
  end
  result
end
 
n = gets.to_i
n.times do
  s, d = gets.split.map!(&:to_i)
  puts f(s, d)
end