module app;

import std.bigint;
import std.conv;
import std.stdio;
import std.string;
import core.bitop;

void main()
{
	writefln("%d", main2(parseInput()).result);
}

BigInt[] count;

static this()
{
    count ~= BigInt(1);
    ulong end = 2;
    while (true)
    {
        count ~= (count[$-1] * 3);
        end <<= 1;
        if (end == 0)
            break;
    }
}

Output main2(Input input)
{
    int rank = bsr(input.r);
    auto temp = calc(rank, input.l, input.r + 1);

    Output output;
    output.result = temp % (10 ^^ 9 + 7);
    return output;
}

BigInt calc(int enclosingRank, ulong begin, ulong end)
{
    if (begin == 2^^enclosingRank && end == 2^^(enclosingRank+1))
        return count[enclosingRank];

    ulong border = 1UL << enclosingRank;
    if (begin <= border && border < end)
        return calc(enclosingRank-1, begin, border) + calc(border, count[enclosingRank], border, end);
    else
        return calc(border, count[enclosingRank], begin, end);
}

unittest
{
    assert(calc(1, 1, 4) == 4);
    assert(calc(1, 2, 4) == 3);
    assert(calc(bsr(1000000000000000000), 1, 1000000000000000000 + 1) % (10^^9 + 7) == 68038601);
}

BigInt calc(ulong width, BigInt rangeTotal, ulong begin, ulong end)
{
    assert (width != 0);
    if (begin + width == end)
        return rangeTotal;

    ulong border = begin + width / 2;
    if (border < end)
        return calc(width / 2, rangeTotal / 3, begin, border) + calc(width / 2, rangeTotal / 3 * 2, border, end);
    else if (border == end)
        return rangeTotal / 3;
    else
        return calc(width / 2, rangeTotal / 3, begin, end);
}

unittest
{
    assert(calc(8, BigInt(27), 8, 16) == 27);
    assert(calc(8, BigInt(27), 8, 15) == 19);
    assert(calc(8, BigInt(27), 8, 14) == 15);
    assert(calc(8, BigInt(27), 8, 13) == 11);
    assert(calc(8, BigInt(27), 8, 12) == 9);
    assert(calc(8, BigInt(27), 8, 11) == 5);
    assert(calc(8, BigInt(27), 8, 10) == 3);
    assert(calc(8, BigInt(27), 8, 9) == 1);
}


struct Input
{
	ulong l;
	ulong r;
}

Input parseInput()
{
	Input input;
    auto lr = readln().strip().split();
	input.l = lr[0].to!ulong;
	input.r = lr[1].to!ulong;
	return input;
}

struct Output
{
    uint result;
}

unittest
{
    Input input = { 2, 3 };
    auto output = main2(input);
    assert(output.result == 3);
}

unittest
{
    Input input = { 10, 100 };
    auto output = main2(input);
    assert(output.result == 604);
}

unittest
{
    Input input = { 1, 1000000000000000000 };
    assert(main2(input).result == 68038601);
}
