Nazar, a student of the scientific lyceum of the Kingdom of Kremland, is known for his outstanding mathematical abilities. Today a math teacher gave him a very difficult task.

Consider two infinite sets of numbers. The first set consists of odd positive numbers ($1, 3, 5, 7, \ldots$), and the second set consists of even positive numbers ($2, 4, 6, 8, \ldots$). At the first stage, the teacher writes the first number on the endless blackboard from the first set, in the second stage — the first two numbers from the second set, on the third stage — the next four numbers from the first set, on the fourth — the next eight numbers from the second set and so on. In other words, at each stage, starting from the second, he writes out two times more numbers than at the previous one, and also changes the set from which these numbers are written out to another. 

The ten first written numbers: $1, 2, 4, 3, 5, 7, 9, 6, 8, 10$. Let's number the numbers written, starting with one.

The task is to find the sum of numbers with numbers from $l$ to $r$ for given integers $l$ and $r$. The answer may be big, so you need to find the remainder of the division by $1000000007$ ($10^9+7$).

Nazar thought about this problem for a long time, but didn't come up with a solution. Help him solve this problem.


-----Input-----

The first line contains two integers $l$ and $r$ ($1 \leq l \leq r \leq 10^{18}$) — the range in which you need to find the sum.


-----Output-----

Print a single integer — the answer modulo $1000000007$ ($10^9+7$).


-----Examples-----
Input
1 3

Output
7
Input
5 14

Output
105
Input
88005553535 99999999999

Output
761141116


-----Note-----

In the first example, the answer is the sum of the first three numbers written out ($1 + 2 + 4 = 7$).

In the second example, the numbers with numbers from $5$ to $14$: $5, 7, 9, 6, 8, 10, 12, 14, 16, 18$. Their sum is $105$.

Difficulty: interview

Starter code:

Solutions:
def f(n, mod):
    res = 0
    n1 = 1
    n2 = 2
    k = 1
    now = 0
    while n >= k:
        if now == 0:
            now = 1
            res = (res + n1 * k + (k * (k - 1))) % mod
            n -= k
            k *= 2
            n1 = n1 + k
        else:
            now = 0
            res = (res + n2 * k + (k * (k - 1))) % mod
            n -= k
            k *= 2
            n2 = n2 + k
    if n == 0:
        return res
    if now == 0:
        return (res + n1 * n + (n * (n - 1))) % mod
    return (res + n2 * n + (n * (n - 1))) % mod

l, r = list(map(int, input().split()))
mod = 10 ** 9 + 7
print((f(r, mod) - f(l - 1, mod)) % mod)


mod = 10**9 + 7

l, r = [int(i) for i in input().split()]

def calc(x):
    cur = 1
    a = []
    b = []
    move = 0
    su = 0
    while su <= x:
        if su+cur>x:
            break
        if move==0:
            a.append(cur)
        else:
            b.append(cur)
        su += cur
        cur*=2
        move^=1
    if su+cur>x:
        if move==0:
            a.append(x-su)
        else:
            b.append(x-su)
        
    return sum(a), sum(b)

def tot(x): # total sum of nums till x nums in list
    odds, evens = calc(x)
    ans = 0
    ans += ((odds%mod)*(odds%mod))%mod
    ans += (((evens%mod)*(evens%mod))%mod + evens)%mod
    return ans%mod

print((tot(r) - tot(l-1))%mod)
    


def helper(n):
    R = 0
    tmp = n + 1
    while tmp != 1:
        tmp >>= 1
        R += 1
    bottom = R >> 1
    top = R - bottom
    flag = (top > bottom)
    tcnt = 0
    tmp = 1
    while top:
        tcnt += tmp
        tmp <<= 2
        top -= 1
    bcnt = 0
    tmp = 2
    while bottom:
        bcnt += tmp
        tmp <<= 2
        bottom -= 1
    n -= tcnt + bcnt
    if flag:
        bcnt += n
    else:
        tcnt += n
    ans = (pow(tcnt, 2, 1000000007) + (bcnt * (bcnt + 1))) % 1000000007
    return ans
        

def main():
    l, r = map(int, input().split())
    ans = helper(r)
    if l != 1:
        ans -= helper(l - 1)
    print(ans % 1000000007)
    return 0
main()

l, r = [int(e) for e in input().split()]

MOD = 1_000_000_007
def sum_range(start, num):
    end = start+(num-1)*2
    return (start+end)*num//2

def sum(n):
    ans = 0
    s = [1, 2]
    cnt = 1
    which = 0
    # print(f"n = {n}", end="")
    while n > 0:
        diff = min(n, cnt)
        ans += sum_range(s[which], diff)
        ans %= MOD
        s[which] += 2*diff
        n -= diff
        cnt *= 2
        which = 1-which
    # print(ans)
    return ans


print(((sum(r)-sum(l-1))%MOD+MOD)%MOD)


def calc(n):
    if n == 0:
        return 0
    k = n.bit_length()
    a = k // 2
    b = k - 1 - a
    c = n - 2**(k-1) + 1
    
    aa = (4**a-1)//3
    bb = 2*(4**b-1)//3
    if k % 2 == 0:
        bb += c
    else:
        aa += c
    
    aaa = aa**2
    bbb = bb * (bb+1)
    return aaa + bbb

l, r = list(map(int, input().split()))
print((calc(r)-calc(l-1))%(10**9+7))



mod = 10 ** 9 + 7
def f(n):
    v = [1, 2]
    cnt = 1
    all = 0
    ans = 0
    while (all < n):
        cnt = min(cnt, n - all)
        all += cnt
        ans += (2 * v[0] + (cnt - 1) * 2) * cnt // 2
        ans %= mod
        v[0] += cnt * 2
        cnt *= 2
        v[0], v[1] = v[1], v[0]
    return ans
l, r = list(map(int, input().split()))
print((f(r) - f(l - 1) + mod * mod) % mod)


MOD = 1000000007
def evensum(n):
    n //= 2
    return (n*(n+1))%MOD
def oddsum(n):
    a = (n*(n+1))//2
    a %= MOD
    a -= evensum(n-1)
    a %= MOD
    return a
def cs(n):
    i = 0
    cn = 1
    tot = 0
    so = -1
    se = 0
    while tot < n:
        cur = min(cn, n-tot)
        if i % 2 == 0:
            so += 2*cur
        else:
            se += 2*cur
        cn *= 2
        tot += cur
        i += 1
    ans = 0
    if se > 0: ans += evensum(se)
    if so > -1: ans += oddsum(so)
    ans %= MOD
    return ans
L, R = list(map(int, input().split()))
ans = cs(R)
if L>1: ans -= cs(L-1)
ans %= MOD
print(ans)


l, r = input().split()

l = int(l)
r = int(r)

MOD = 10**9+7

def f(v) :
    nonlocal MOD
    ret = 0
    r = 0
    
    p1, p2 = 0, 0

    while (v>>r) > 0:
        if r&1 == 0:
            p1 += min(v+1, 1<<r+1)-(1<<r)
        else :
            p2 += min(v+1, 1<<r+1)-(1<<r)
        r += 1
    
    return (p1*p1+p2*(p2+1))%MOD
print((f(r)-f(l-1)+MOD)%MOD)

l, r = list(map(int, input().split()))
l -= 1
if l == 0:
    ar1 = []
else:
    ar1 = [1]
sum1 = 1
while sum1 < l:
    if sum1 + ar1[-1] * 2 <= l:
        sum1 += ar1[-1] * 2
        ar1.append(ar1[-1] * 2)
    else:
        ar1.append(l - sum1)
        sum1 = l

ar2 = [1]
sum2 = 1
while sum2 < r:
    if sum2 + ar2[-1] * 2 <= r:
        sum2 += ar2[-1] * 2
        ar2.append(ar2[-1] * 2)
    else:
        ar2.append(r - sum2)
        sum2 = r

sum1_odd = sum(ar1[::2])
sum1_even = sum(ar1[1::2])
sum2_odd = sum(ar2[::2])
sum2_even = sum(ar2[1::2])
p = 10 ** 9 + 7
print((sum2_odd ** 2 + sum2_even ** 2 + sum2_even - sum1_odd ** 2 - sum1_even ** 2 - sum1_even) % p)


from math import log

def howManyOdds(n):
    l = int(log(n+1, 2))
    if l%2 == 1:
        return (4**((l+1)//2) - 1) // 3
    else:
        return n - howManyEvens(n)

def howManyEvens(n):
    l = int(log(n+1, 2))
    if l%2 == 1:
        return n - howManyOdds(n)
    else:
        return (4**((l+1)//2) - 1) // 3 * 2

def firstEvens(n):
    return n * (n+1)

def firstOdds(n):
    return firstEvens(n) - n

def f(n):
    return firstEvens(howManyEvens(n)) + firstOdds(howManyOdds(n))

a, b = [int(i) for i in input().split()]
print((f(b) - f(a-1)) % (10**9 + 7))


import getpass
import sys

if getpass.getuser() != 'frohenk':
    filename = 'half'
    # sys.stdin = open('input.txt')
    # sys.stdout = open('output.txt', 'w')
else:
    sys.stdin = open('input.txt')
    # sys.stdin.close()

import math
import string
import re
import math
import random
from decimal import Decimal, getcontext

mod = 10 ** 9 + 7


def ria():
    return [int(i) for i in input().split()]


def alg_s(b, s, n):
    # print(b, b + s * (n - 1))

    return ((b + s * (n - 1) + b) * n // 2) % mod


L, R = ria()
cr1 = 1
cr2 = 2
lk = 1
cr = 1
is1 = True
ans = 0
for j in range(300):
    l = cr
    r = cr + lk - 1

    if is1:
        if l >= L and r <= R:
            ans += alg_s(cr1, 2, r - l + 1)
        elif L >= l and R <= r:
            ans += alg_s(cr1 + (L - l) * 2, 2, R - L + 1)
        elif r >= L >= l:
            ans += alg_s(cr1 + (L - l) * 2, 2, r - L + 1)
            # print('A')
        elif l <= R <= r:
            ans += alg_s(cr1, 2, R - l + 1)
            # print('B')
        cr1 += (r - l + 1) * 2
    else:
        if l >= L and r <= R:
            ans += alg_s(cr2, 2, r - l + 1)
        elif L >= l and R <= r:
            ans += alg_s(cr2 + (L - l) * 2, 2, R - L + 1)
        elif r >= L >= l:
            ans += alg_s(cr2 + (L - l) * 2, 2, r - L + 1)
            # print('C')
        elif l <= R <= r:
            ans += alg_s(cr2, 2, R - l + 1)
            # print('D')

        cr2 += (r - l + 1) * 2

    is1 = not is1
    cr += cr
    lk *= 2
    ans %= mod
print(ans)


from math import log

def f(n):
	l = int(log(n + 1, 2)) - 1
	n0 = n - 2**(l + 1) + 1
	x = 0
	y = 0
	for i in range(l + 1):
		if i % 2 == 0:
			x += 2**(i)
		else:
			y += 2**(i)
	if l % 2 != 0:
		x += n0
	else:
		y += n0
	return (x, y)

MOD = 10**9 + 7
l, r = map(int, input().split())
L = f(l - 1)
R = f(r)
x1, y1 = L
x2, y2 = R
ans = 0
ans += x2**2 % MOD
ans -= x1**2 % MOD
ans += y2*(y2 + 1) % MOD
ans -= y1*(y1 + 1) % MOD
print(ans % MOD)


p = 10 ** 9 + 7


def sum_even(n):
    return n * (n + 1) % p if n > 0 else 0


def sum_odd(n):
    return (n + sum_even(n - 1)) % p if n > 0 else 0


def sum_special(n):
    if n < 1:
        return 0
    d = 1
    i = 0
    s = [0, 0]
    k = 0
    while i < n:
        s[k] += min(d, n - i)
        k = (k + 1) % 2
        i += d
        d *= 2
    return (sum_odd(s[0]) + sum_even(s[1])) % p


l, r = list(map(int, input().split()))

print((p + sum_special(r) - sum_special(l - 1)) % p)


l , r = list(map(int,input().split()))

mod = 10**9+7

def f(l):
    left = 0
    c = 0
    while left < l:
        left += pow(2,c)
        c+=1


    extra = left - l
    #print(extra)
    ls = 0
    odd  = 0
    eve = 0

    for i in range(c):
        if i%2 == 0:
            odd += pow(2,i)
        else:
            eve += pow(2,i)
    temp = 0
    if c%2 == 1:
        temp = (odd-extra)*(odd-extra) + eve*(eve+1)
    else:
        temp = odd*odd + (eve-extra)*(eve+1-extra)

    return temp


print( (f(r) - f(l-1) + mod)%mod )


mod = 1000000007

def f(n):
    f = 1
    s = 2
    t = 1
    ret = 0
    cnt = 0
    p = 1
    while cnt + p <= n:
        cnt += p
        if t == 1:
            ret = (ret + (2 * f + (p - 1) * 2) * p // 2) % mod
            f += 2 * p
        else :
            ret = (ret + (2 * s + (p - 1) * 2) * p // 2) % mod
            s += 2 * p
        p *= 2
        t += 1
        if t > 2:
            t = 1
    if t == 1:
        ret = (ret + (2 * f + (n - cnt - 1) * 2) * (n - cnt) // 2) % mod
    else:
        ret = (ret + (2 * s + (n - cnt - 1) * 2) * (n - cnt) // 2) % mod
    return ret

l, r = list(map(int, input().split()))
print((f(r) - f(l - 1) + mod) % mod)


import sys
input = sys.stdin.readline

l,r=list(map(int,input().split()))

mod=10**9+7
def calc(n):
    NOW=0
    NOWO=0
    NOWE=0

    OE=1
    i=0

    while True:
        if NOW+(1<<i)<=n:
            NOW+=(1<<i)
            if OE==1:
                NOWO+=(1<<i)
            else:
                NOWE+=(1<<i)

            OE=1-OE            
            i+=1

        else:
            if OE==1:
                NOWO+=n-NOW
            else:
                NOWE+=n-NOW

            break

    return (NOWO,NOWE)

O,E=calc(l-1)
SUM0=O**2+(E+1)*E

O,E=calc(r)
SUM1=O**2+(E+1)*E

print((SUM1-SUM0)%mod)


            
        


def sumto(l):
    n = 1
    o = 1
    e = 2
    S = 0
    i = 0
    par = 0
    t = 0
    while 1:
        par = 1 - par
        t += n
        if t >= l:
            t -= n
            n = l - t
            if par:
                S += n*o + n*(n-1)
                o += 2*n
                n *= 2
            else:
                S += n*e + n*(n-1)
                e += 2*n
                n *= 2
            break
        if par:
            S += n*o + n*(n-1)
            o += 2*n
            n *= 2
        else:
            S += n*e + n*(n-1)
            e += 2*n
            n *= 2
        i += 1
    return S

l,r = list(map(int,input().split()))
mod = 10**9 + 7
print((sumto(r) - sumto(l-1))%mod)


def calc_even(n):
    if n<=1:
        return 0
    i=1
    while 2**i <= n:
        i+=2
    i-=2
    cnt=2*(2**i-2**(i-1)-1)//3
    if 2**i+2**i-1<n:
        cnt+=2**i
    else:
        cnt+=n-2**i+1
    return cnt*(cnt+1)

def calc_odd(n):
    if n<1:
        return 0
    i=0
    while 2**i <= n:
        i+=2
    i-=2
    cnt=(2**i-1)//3
    if 2**i+2**i-1<n:
        cnt+=2**i
    else:
        cnt+=n-2**i+1
    return cnt*cnt

l, r = [int(x) for x in input().split()]
ans = calc_odd(r)-calc_odd(l-1) + calc_even(r)-calc_even(l-1)
print(ans % 1000000007)