-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import Data.Bits
import Data.Coerce
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

integerLog2 :: Integer -> Int
integerLog2 x | x <= 0 = error "integerLog2"
integerLog2 x = floor (logBase 2 (fromInteger x) :: Double)

int64Log2 :: Int64 -> Int
int64Log2 = integerLog2 . fromIntegral

naive :: Int64 -> Int64 -> [(Int64, Int64)]
naive l r = [(x,y) | x <- [l..r], y <- [x..r], y `rem` x == y `xor` x]

solve :: Int64 -> Int64 -> N
solve l r | l > r  = 0
          | l == r = 1
          | log2l == log2r = solve2 l r log2l
          | otherwise = sum $ map loop [log2l .. log2r]
  where
    log2l = int64Log2 l
    log2r = int64Log2 r
    loop i | i == log2l = solveL l i
           | i == log2r = solveR r i
           | otherwise = 3^i
    solve2 l r i | int64Log2 l /= i || int64Log2 r /= i = error ("invalid " ++ show (l,r,i))
                 | otherwise = loop i
      where loop i | i < 0 = 1
                   | otherwise = case (testBit l i, testBit r i) of
                                   (False, False) -> loop (i-1)
                                   (False, True) -> solveL l (i-1) + solveR r (i-1) + if l .&. (2^i-1) <= r .&. (2^i-1) then loop (i-1) else 0
                                   (True, True) -> loop (i-1)
                                   _ -> error "invalid"

solveL l i | i < 0 = 1
           | otherwise = if testBit l i
                         then solveL l (i-1)
                         else 2 * solveL l (i-1) + 3^i

solveR r i | i < 0 = 1
           | i == int64Log2 r = solveR r (i-1)
           | otherwise = if testBit r i
                         then 2 * solveR r (i-1) + 3^i
                         else solveR r (i-1)

main = do
  [l,r] <- map fromInteger . unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  print $ solve l r

--
-- Modular Arithmetic
--

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}
