local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local n, q = io.read("*n", "*n", "*l") for iq = 1, q do local s, t = io.read():match("(%d+) (%d+)") s = lltonumber(s) t = lltonumber(t) local z = 0 while 0LL < t - s do local len = t - s local jump1 = 1LL while s % (2LL * jump1) == 0LL and jump1 * 2LL <= len do jump1 = jump1 * 2LL end z = z + 1 s = s + jump1 end print(z) end