let d1 (x, y, l, r) s =
  match x, y, s with
    1, 0, 0 -> 1
  | 0, 1, 0 -> 1
  | 1, 1, 0 -> 2
  | _, _, _ -> s
let a1 = (d1, [0; 2])

let d2 (x, y, l, r) s =
  match x, l, s with
    1, 0, 0 -> 1
  | 0, 1, 0 -> 2
  | _, _, _ -> s
let a2 = (d2, [0; 1])

let d3 (x, y, l, r) s =
  match y, r, s with
    1, 0, 0 -> 1
  | 0, 1, 0 -> 2
  | _, _, _ -> s
let a3 = (d3, [0; 2])

let d4 (x, y, l, r) s =
  match x, y, s with
    1, 0, 0 -> 1
  | _, _, _ -> s
let a4 = (d4, [0])

let aus = [a1; a2; a3; a4]

let mo = 1_000_000_007

let () = Scanf.scanf "%d %d" @@ fun l r ->
  let a = Array.make (60 * 81) (-1) in
  let rec f i ss =
    let j = List.fold_left (fun x y -> x * 3 + y) 0 ss in
    if i < 0
    then if List.for_all2 (fun s (_, acs) -> List.mem s acs) ss aus
         then 1
         else 0
    else if a.(i * 81 + j) <> -1
         then a.(i * 81 + j)
         else let v = List.fold_left (fun s (a, b) ->
                          let ss = List.map2 (fun s (d, _) -> d (a, b, (l lsr i) land 1, (r lsr i) land 1) s) ss aus in
                          (s + f (i - 1) ss) mod mo) 0 [(0, 0); (0, 1); (1, 0); (1, 1)] in
              let () = a.(i * 81 + j) <- v in
              a.(i * 81 + j) in
  Printf.printf "%d\n" @@ f 59 [0; 0; 0; 0]

