#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<1000000007>;


ll L, R;

/*
	2進数で
	x = 0aaa
	y = 1bbb
	  →  y^x = 1ccc これは y mod x より大きい
	
	x = 1aaa
	y = 0bbb
	  → x <= y にならない
	   
	x = 1aaa
	y = 1bbb
	  → y^x = 0ccc の形になり x<=y なら y mod x = y - x
	     aaa^bbb = bbb-aaa
	     aaa & ~bbb = 0 であればよい
	
	
	
	
	2^k <= x <= y <= 2^k+r < 2^(k+1)
	
	y = 1ddddeeeeeeee で d が固定の場合
	

*/

mint maskbitnum_to_count[60];


string llstr( ll x ){
	string s(" ");
	for ( int i = 0; i < 16; i++ ){
		s += ( x & (1LL<<(15-i))) ? "1" : "0";
	}
	return s;
}

ll call_ct = 0;
ll call_1 = 0;
ll call_0 = 0;
ll call_n = 0;

ll count( ll xpattern, ll ypattern, ll mask, ll maskbitnum ){
	call_ct++;
	
	if ( ypattern+mask < L || xpattern+mask < L || R < xpattern || R < ypattern ){
		call_0++;
		return 0;
	}
	
	if ( maskbitnum == 0 ){
		//cout << "count 1 : " << xpattern << " " << ypattern << endl;
		call_1++;
		return 1;
	}
	
	if ( L <= xpattern && ypattern+mask <= R ){
		//cout << "count " << maskbitnum_to_count[maskbitnum].value() << " : " << xpattern << "," << ypattern << " / " << llstr(xpattern) << llstr(ypattern) << llstr(mask) << endl;
		call_n++;
		return maskbitnum_to_count[maskbitnum].value();
	}
	else {
		ll mask2 = mask>>1;
		ll b = mask ^ mask2;
		
		ll ct = 0;
		if ( L <= xpattern ){
			ct += count( xpattern  , ypattern  , mask2, maskbitnum-1 );
			ct += 2*count( xpattern  , ypattern|b, mask2, maskbitnum-1 );
		}
		else if ( (ypattern|b)+mask2 <= R ){
			ct += 2*count( xpattern  , ypattern  , mask2, maskbitnum-1 );
			ct += count( xpattern|b, ypattern|b, mask2, maskbitnum-1 );
		}
		else {
			ct += count( xpattern  , ypattern  , mask2, maskbitnum-1 );
			ct += count( xpattern  , ypattern|b, mask2, maskbitnum-1 );
			ct += count( xpattern|b, ypattern|b, mask2, maskbitnum-1 );
		}
		return ct % 1000000007;
	}
}






int main(){
	cin >> L >> R;
	
	mint a = 1;
	for ( int i = 0; i < 60; i++ ){
		maskbitnum_to_count[i] = a;
		a *= 3;
	}
	
	ll ct = 0;
	for ( int i = 0; i < 60; i++ ){
		ct += count( 1LL<<i, 1LL<<i, (1LL<<i)-1, i );
	}
	//cout << call_ct << "/ 0:" << call_0 << " 1:" << call_1 << " n:" << call_n << endl;
	cout << (ct % 1000000007) << endl;
	
	return 0;
}



Measured memory_bytes: 256