l,r = gets.split.map(&:to_i)
mod = 10**9+7
ans, lb, rb = 0, l.bit_length, r.bit_length

if rb > lb
	ones=l.to_s(2).reverse.each_char.with_index.map { |a, i| a == '0' ? i : nil }.compact.reverse
	i = 0
	ones.each do |one|
		ans+= ((3**one) * (2**i)) % mod
		i += 1
	end
	ans += 2**i % mod
	
	((lb+1)...rb).each do |xb|
		ans += (3**(xb-1)%mod)
	end
	ones=r.to_s(2).reverse.each_char.with_index.map { |a, i| a == '1' ? i : nil }.compact.reverse
	i = 0
	ones[1..-1].each do |one|
		ans+= ((3**one) * (2**i)) % mod
		i += 1
	end
  	ans += 2**i % mod
else
	(l..r).each do |x|
		ans += (x..r).map do |y|
			(y-x)==(y^x)
		end.count(true) % mod
	end
end
p ans%mod