#include <bits/stdc++.h>
#define MOD 1000000007
template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    explicit operator int() const { return x; }                           // added by QCFium
    ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            std::swap(a,b);
            u-=t*v;
            std::swap(u,v);
        }
        return ModInt(u);
    }
    friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};
typedef ModInt<MOD> mint;


int cnt(int64_t n) {
	int res = 0;
	while (n) n >>= 1, res++;
	return res;
}
std::string too_string(int64_t n, int size) {
	std::string res;
	while (n) res.push_back('0' + (n & 1)), n >>= 1;
	assert((int)res.size() <= size);
	while ((int) res.size() < size) res.push_back('0');
	std::reverse(res.begin(), res.end());
	return res;
}

mint calc(const std::string &a, const std::string &b) {
	assert(a.size() == b.size());
	int n = a.size();
	mint res = 1;
	for (int i = 0; i < n; i++) {
		if (b[i] == '*') {
			if (a[i] == '*') res *= 3;
			else if (a[i] == '0') res *= 2;
		} else if (b[i] == '1') {
			if (a[i] == '*') res *= 2;
		} else if (b[i] == '0') {
			if (a[i] == '1') return 0;
		}
	}
	return res;
}
std::vector<std::string> get_all(const std::string &limit, bool inclusive) {
	std::vector<std::string> all;
	if (inclusive) all.push_back(limit);
	int n = limit.size();
	for (int j = 0; j < n; j++) {
		if (limit[j] == '1') {
			std::string cur = limit;
			cur[j] = '0';
			for (int k = j + 1; k < n; k++) cur[k] = '*';
			all.push_back(cur);
		}
	}
	return all;
}

int main() {
	int64_t l, r;
	std::cin >> l >> r;
	int cl = cnt(l);
	int cr = cnt(r);
	mint res = 0;
	for (int i = cl; i <= cr; i++) {
		// [1 << (i - 1), 1 << i)
		
		if (i != cl && i != cr) res += calc(std::string(i - 1, '*'), std::string(i - 1, '*'));
		else if (i != cl) {
			std::string limit = too_string(r - (1LL << (i - 1)), i - 1);
			std::vector<std::string> all = get_all(limit, true);
			// for (auto &j : all) std::cerr << j << " ";
			// std::cerr << std::endl;
			for (auto &j : all) for (auto &k : all) res += calc(j, k);
		} else if (i != cr) {
			std::string limit = too_string(l - (1LL << (i - 1)), i - 1);
			std::vector<std::string> low = get_all(limit, false);
			res += calc(std::string(i - 1, '*'), std::string(i - 1, '*'));
			for (auto &j : low) res -= calc(j, std::string(i - 1, '*'));
		} else {
			std::string lower = too_string(l - (1LL << (i - 1)), i - 1);
			std::string upper = too_string(r - (1LL << (i - 1)), i - 1);
			auto up = get_all(upper, true);
			auto low = get_all(lower, false);
			for (auto &j : up) for (auto &k : up) res += calc(j, k);
			for (auto &j : low) for (auto &k : up) res -= calc(j, k);
		}
	}
	std::cout << res << std::endl;
	
	
	return 0;
}


Measured memory_bytes: 256