#べき乗(MODあり)(繰り返し２乗法)
def pow(x, n, mod)
  ans = 1
  while n > 0
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  ans
end

L, R = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

llog = (Math.log(L+1) / Math.log(2)).ceil
rlog = (Math.log(R) / Math.log(2)).ceil
m = 0
((llog+1)...rlog).each{|i|
  m += pow(3, i - 1, MOD)
}

def count_fraction(fraction, len, &b)
  wk = fraction
  ret, cnt = [0, 0]
  (1...len).each{|c|
    if b.call(wk) then
      ret = (2 * ret + pow(3, c - 1, MOD)) % MOD
      cnt += 1
    end
    wk >>= 1
  }
  (ret + pow(2, cnt, MOD)) % MOD
end

l = count_fraction(L, llog){|n| n.even?}

if llog == rlog then
  r = 0
else
  r = count_fraction(R, rlog){|n| n.odd?}
end

puts (m + l + r) % MOD
