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$.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Mathematics

Constructive algorithms


Solutions:
def f(n):
	if n == 0:
		return 0
	(l, v, t, cnt) = ([1, 0], 2, 1, 1)
	while cnt + v <= n:
		l[t] += v
		(v, t, cnt) = (2 * v, 1 - t, cnt + v)
	l[t] += n - sum(l)
	return l[0] * l[0] + l[1] * (l[1] + 1)
(l, r) = map(int, input().split(' '))
ans = (f(r) - f(l - 1)) % 1000000007
print(ans)


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
mod = 10 ** 9 + 7
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	max_so_far = -sys.maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0, size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i + 1
	return (max_so_far, start, end)

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	end_number = [1, 4]
	for i in range(2, 65):
		a = end_number[i - 2] + 2
		end_number.append(a + (2 ** i - 1) * 2)
	(l, r) = num_input()
	lower = math.floor(math.log(l, 2))
	upper = math.floor(math.log(r, 2))
	summ = 0
	if lower == upper:
		if lower == 0:
			print(1)
			return
		left = end_number[lower]
		a = left - 2 * (int(pow(2, lower)) - 1)
		l -= int(pow(2, lower)) - 1
		a = a + (l - 1) * 2
		r -= int(pow(2, lower)) - 1
		n = r - l + 1
		summ = n * (a + n - 1) % mod
		print(summ)
		return
	if lower != 0:
		left = end_number[lower]
		a = left - 2 * (int(pow(2, lower)) - 1)
		l -= int(pow(2, lower)) - 1
		a = a + (l - 1) * 2
		n = int(pow(2, lower)) - l + 1
		summ += n * (a + n - 1) % mod
	else:
		summ += 1
	right = end_number[upper]
	a = right - 2 * (int(pow(2, upper)) - 1)
	r -= int(pow(2, upper)) - 1
	summ = (r * (a + r - 1) + summ) % mod
	for i in range(lower + 1, upper):
		left = end_number[i]
		a = left - 2 * (int(pow(2, i)) - 1)
		n = int(pow(2, i))
		summ = (n * (a + n - 1) + summ) % mod
	print(summ)
t = 1
for _ in range(t):
	solve()


import getpass
import sys
if getpass.getuser() != 'frohenk':
	filename = 'half'
else:
	sys.stdin = open('input.txt')
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):
	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)
		elif l <= R <= r:
			ans += alg_s(cr1, 2, R - l + 1)
		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)
		elif l <= R <= r:
			ans += alg_s(cr2, 2, R - l + 1)
		cr2 += (r - l + 1) * 2
	is1 = not is1
	cr += cr
	lk *= 2
	ans %= mod
print(ans)


def nodds(n):
	return n ** 2

def nevens(n):
	return n ** 2 + n

def neach(n):
	i = 1
	mode = True
	reach = 0
	odds = 0
	evens = 0
	while reach + i < n:
		if mode:
			odds += i
			mode = False
		else:
			evens += i
			mode = True
		reach += i
		i *= 2
	if mode:
		odds += n - reach
	else:
		evens += n - reach
	return (odds, evens)

def sm(n):
	x = neach(n)
	return nevens(x[1]) + nodds(x[0])
(l, r) = input().split()
(l, r) = (int(l), int(r))
print((sm(r) - sm(l - 1)) % 1000000007)


import math

def calc(k):
	if k == 0:
		return 0
	result = 0
	mod = 1
	lower_odd = 1
	lower_even = 2
	length = 1
	while k > 0:
		if mod == 1:
			upper_odd = lower_odd + 2 * (length - 1)
			result += (upper_odd + lower_odd) * length // 2
			lower_odd = upper_odd + 2
		else:
			upper_even = lower_even + 2 * (length - 1)
			result += (upper_even + lower_even) * length // 2
			lower_even = upper_even + 2
		mod ^= 1
		k -= length
		length *= 2
		length = min(length, k)
	return result
(l, r) = map(int, input().split())
result = (calc(r) - calc(l - 1)) % (10 ** 9 + 7)
print(result)


MOD = 10 ** 9 + 7

def geteo(x):
	n = e = o = 0
	while 2 ** (n + 1) - 1 <= x:
		if n % 2:
			e += 1 << n
		else:
			o += 1 << n
		n += 1
	x -= e + o
	if n % 2:
		e += x
	else:
		o += x
	return (e, o)

def arsum(a, n, d=2):
	return n * (2 * a + d * (n - 1)) // 2 % MOD

def calc(x):
	(e, o) = geteo(x)
	return (arsum(2, e) + arsum(1, o)) % MOD
(l, r) = map(int, input().split())
print((calc(r) - calc(l - 1)) % MOD)


mod = 10 ** 9 + 7

def cal(val):
	global mod
	if val == 0:
		return 0
	odd = 0
	eve = 0
	su = 0
	i = 0
	while 1:
		if i % 2:
			eve += 1 << i
		else:
			odd += 1 << i
		su += 1 << i
		i += 1
		if su + (1 << i) > val:
			fin = val - su
			if i % 2:
				eve += fin
			else:
				odd += fin
			break
	eve_sum = eve * (1 + eve)
	odd_sum = odd * odd
	return (eve_sum + odd_sum) % mod
(l, r) = [int(i) for i in input().split()]
print((cal(r) - cal(l - 1)) % mod)


(L, R) = tuple(list(map(int, input().split(' '))))
L = L - 1
ans = 0
oidx = 0
eidx = 0
csum = 0
cnt = 1
mod = int(1000000000.0 + 7)
i = 1
while csum <= R:
	l = max([csum, L])
	csum += cnt
	r = min([R, csum])
	if i % 2 == 1:
		oidx += cnt
	else:
		eidx += cnt
	cnt *= 2
	bv = 1 if i % 2 == 1 else 2
	bv += 2 * (l - (eidx if i % 2 == 1 else oidx))
	i += 1
	if r <= l:
		continue
	ev = bv + (r - l - 1) * 2
	ans += (bv + ev) * (r - l) // 2 % mod
print(ans % mod)


hell = 1000000007
s0 = 0
se = 0

def find(n):
	if n == 0:
		so = 0
		se = 0
		return (so, se)
	if n == 1:
		so = 1
		se = 0
		return (so, se)
	i = 1
	k = 1
	so = 0
	se = 0
	while so + se + i <= n:
		if k == 1:
			so += i
			i *= 2
		else:
			se += i
			i *= 2
		k = k * -1
	if k == 1:
		so += n - (so + se)
	else:
		se += n - (so + se)
	so = so % hell
	se = se % hell
	return (so, se)
(l, r) = map(int, input().split())
(so, se) = find(l - 1)
ans = so * so % hell + (1 + se) * se % hell
(so, se) = find(r)
ans1 = so * so % hell + (1 + se) * se % hell
print((ans1 - ans) % hell)


MOD = int(1000000000.0 + 7)

def binExp(b, pw):
	if pw == 0:
		return 1
	return binExp(b * b % MOD, int(pw // 2)) * (b if pw & 1 else 1) % MOD

def mod_inv(a):
	return binExp(a, MOD - 2)

def sumCons(n):
	return n * (n + 1) * mod_inv(2)

def modMul(a, b):
	return a * b % MOD

def sumE(l, r):
	return (modMul(sumCons(r), 2) - modMul(sumCons(l), 2) + MOD) % MOD

def sumO(l, r):
	return (modMul(sumCons(r), 2) - r - (modMul(sumCons(l), 2) - l) + MOD) % MOD

def f(x):
	isO = True
	oCnt = 0
	eCnt = 0
	pw = 1
	val = 0
	while x > 0:
		num = min(x, pw)
		if isO:
			val += sumO(oCnt, oCnt + num)
			val %= MOD
			oCnt += num
		else:
			val += sumE(eCnt, eCnt + num)
			val %= MOD
			eCnt += num
		val += MOD
		val %= MOD
		isO = not isO
		pw *= 2
		x -= num
	return val
(l, r) = [int(i) for i in input().split()]
print((f(r) - f(l - 1) + MOD) % MOD)


(l, r) = map(int, input().split())
MAX_POWER = 64
mod = 10 ** 9 + 7

def get_two_power(num):
	two_nums = 0
	two_power = 1
	while two_power * 2 - 1 < num:
		two_nums += 1
		two_power *= 2
	if two_power * 2 - 1 == num:
		return (two_nums, 0)
	else:
		return (two_nums - 1, num - two_power + 1)

def get_odd_even_numbers(num):
	(two_nums, remaining_numbers) = get_two_power(num)
	odd_power_list = ['0'] * MAX_POWER
	even_power_list = ['0'] * MAX_POWER
	for i in range(two_nums + 1):
		if i % 2 == 0:
			odd_power_list[i] = '1'
		else:
			even_power_list[i] = '1'
	first_odd_numbers = int(''.join(odd_power_list[::-1]), base=2)
	first_even_numbers = int(''.join(even_power_list[::-1]), base=2)
	if two_nums % 2 == 0:
		first_even_numbers += remaining_numbers
	else:
		first_odd_numbers += remaining_numbers
	return (first_odd_numbers, first_even_numbers)

def sum_first_odd_even_numbers(first_odd, first_even):
	return (pow(first_odd, 2, mod) + first_even * (first_even + 1) % mod) % mod

def get_sum(num):
	if not num:
		return 0
	(first_odd, first_even) = get_odd_even_numbers(num)
	return sum_first_odd_even_numbers(first_odd, first_even)
res = get_sum(r) - get_sum(l - 1)
if res < 0:
	res += mod
print(res)


(l, r) = input().split(' ')
l = int(l)
r = int(r)
w1 = 0
w2 = 0
d = 1
cur = 0
q = 1
while cur + d < l:
	if q == 1:
		w1 += d
	else:
		w2 += d
	cur += d
	d = d * 2
	q = 1 - q
arr = [[0, 0], [0, 0]]
arr[0][0] = w2
arr[0][1] = w1
if cur + d <= r:
	w = cur + d - l + 1
	if q == 1:
		w1 += d - w
	else:
		w2 += d - w
	arr[0][0] = w2
	arr[0][1] = w1
	if q == 1:
		w1 += w
	else:
		w2 += w
	cur += d
	d = d * 2
	q = 1 - q
	while cur + d <= r:
		if q == 1:
			w1 += d
		else:
			w2 += d
		cur += d
		d = d * 2
		q = 1 - q
	if cur != r:
		if q == 1:
			w1 += r - cur
		else:
			w2 += r - cur
else:
	if q == 1:
		w1 += l - cur - 1
	else:
		w2 += l - cur - 1
	arr[0][0] = w2
	arr[0][1] = w1
	if q == 1:
		w1 += r - l + 1
	else:
		w2 += r - l + 1
arr[1][0] = w2
arr[1][1] = w1
M = 1000000007
ans = arr[1][0] % M * (arr[1][0] + 1) % M % M
ans -= arr[0][0] % M * (arr[0][0] + 1) % M % M
ans += arr[1][1] % M * (arr[1][1] + 1) % M % M - arr[1][1]
ans = ans % M
ans -= arr[0][1] % M * (arr[0][1] + 1) % M % M - arr[0][1]
ans = ans % M
print(ans)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(l, r) = int_array()
odd = 1
even = 2
x = 1
ans = 0
for i in range(60):
	if i % 2 == 0:
		a = x
		b = 2 * x - 1
		sts = odd
		end = odd + (x - 1) * 2
		odd += x * 2
	else:
		a = x
		b = 2 * x - 1
		sts = even
		end = even + (x - 1) * 2
		even += x * 2
	if l >= a:
		if l <= b:
			sts += (l - a) * 2
			if r <= b:
				end -= (b - r) * 2
				y = (end - sts) // 2 + 1
				ans += y * (sts + end) // 2
				break
			else:
				y = (end - sts) // 2 + 1
				ans += y * (sts + end) // 2
	elif r <= b:
		end -= (b - r) * 2
		y = (end - sts) // 2 + 1
		ans += y * (sts + end) // 2
		break
	else:
		ans += x * (end + sts) // 2
	ans %= MOD
	x *= 2
print(ans % MOD)


(l, r) = input().split()
k = 0
p1 = 0
p2 = 0
is_n = 1
while p1 + p2 < int(l):
	if is_n:
		p1 += 1 << k
	else:
		p2 += 1 << k
	if is_n == 1:
		is_n = 0
	else:
		is_n = 1
	k += 1
tmp = abs(int(l) - 1 - p1 - p2)
if is_n == 0:
	p1 -= tmp
else:
	p2 -= tmp
otv1 = (2 + 2 * (p1 - 1)) * p1 // 2
otv2 = (4 + 2 * (p2 - 1)) * p2 // 2
k = 0
p1 = 0
p2 = 0
is_n = 1
while p1 + p2 <= int(r):
	if is_n:
		p1 += 1 << k
	else:
		p2 += 1 << k
	if is_n == 1:
		is_n = 0
	else:
		is_n = 1
	k += 1
tmp = abs(int(r) - p1 - p2)
if is_n == 0:
	p1 -= tmp
else:
	p2 -= tmp
otv3 = (2 + 2 * (p1 - 1)) * p1 // 2
otv4 = (4 + 2 * (p2 - 1)) * p2 // 2
print((otv3 + otv4 - (otv1 + otv2)) % 1000000007)


import math

def find(n):
	if n == 0:
		return 0
	x = int(math.log2(n + 1))
	so1 = (pow(4, math.ceil(x / 2)) - 1) // 3
	se1 = 2 * (pow(4, math.floor(x / 2)) - 1) // 3
	so = so1 ** 2
	se = 2 * (se1 * (se1 + 1))
	if x // 2 == x / 2:
		t = n - so1 - se1
		so = pow(so1 + t, 2, 10 ** 9 + 7)
		se = se1 * (se1 + 1) % (10 ** 9 + 7) % (10 ** 9 + 7)
	else:
		t = n - so1 - se1
		so = pow(so1, 2, 10 ** 9 + 7)
		se1 += t
		se = se1 * (se1 + 1) % (10 ** 9 + 7) % (10 ** 9 + 7)
	return (so + se) % (10 ** 9 + 7)

def main():
	(l, r) = map(int, input().split())
	print((find(r) - find(l - 1)) % (10 ** 9 + 7))
main()


import sys
import copy
sys.setrecursionlimit(1000000)
mod = 1000000000 + 7

def pow_mod(n, p):
	ret = 1
	while p > 0:
		if p & 1:
			ret = ret * n % mod
		n = n * n % mod
		p >>= 1
	return ret

def getD(a, n, d):
	return (2 * a % mod + (n - 1) * d % mod) % mod * n % mod * pow_mod(2, mod - 2) % mod

def f(A):
	even = 1
	odd = 1
	now = 0
	sum = 0
	turn = 0
	D = 1
	while True:
		if now == A:
			break
		if turn % 2 == 0:
			d = min(D, A - now)
			sum += getD(odd * 2 - 1, d, 2)
			odd += d
			now += d
			sum %= mod
		else:
			d = min(D, A - now)
			sum += getD(even * 2, d, 2)
			even += d
			now += d
			sum %= mod
		turn += 1
		D *= 2
	return sum
(L, R) = map(int, input().split())
left = f(L - 1)
right = f(R)
print((right - left + mod) % mod)


mod = 10 ** 9 + 7

def cal(k):
	c = x = y = od = ev = 0
	y = 1
	while c + y <= k:
		c += y
		if x % 2:
			ev += y
		else:
			od += y
		y *= 2
		x += 1
	if x % 2:
		ev += k - c
	else:
		od += k - c
	return od * od + ev * (ev + 1)
(l, r) = [int(x) for x in input().split(' ')]
print((cal(r) - cal(l - 1) + mod) % mod)


import sys, math, queue
MOD = 10 ** 9 + 7

def solve(x):
	odev = [0, 0]
	y = 0
	for i in range(62):
		a = 1 << i
		if y + a > x:
			odev[i & 1] += x - y
			break
		odev[i & 1] += a
		y += a
	ans = (odev[0] * odev[0] % MOD + (odev[1] + 1) * odev[1] % MOD) % MOD
	return ans
(l, r) = map(int, input().split())
print((MOD + solve(r) - solve(l - 1)) % MOD)


(l, r) = [int(t) for t in input().split()]
l -= 2
r -= 1
mod = 7 + 10 ** 9

def calc(st, n):
	st -= 1
	return st * n % mod + n * n * 2 // 2 % mod

def sum_first_k(k):
	ans = 0
	cur_pos = 0
	p = 0
	st = [1, 2]
	i_st = 0
	while True:
		ans += calc(st[i_st], 2 ** p) % mod
		p += 1
		st[i_st] += 2 ** p
		i_st = (i_st + 1) % 2
		if cur_pos + 2 ** p > k:
			break
		cur_pos += 2 ** p
	ans += calc(st[i_st], k - cur_pos) % mod
	return ans % mod

def solve(l, r):
	if l == r:
		return 0
	if l == -1:
		return (sum_first_k(r) - sum_first_k(l) + 1) % mod
	return (sum_first_k(r) - sum_first_k(l)) % mod
print(solve(l, r))


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

def odd(x):
	return x ** 2

def even(x):
	return x * (x + 1)

def ans(x):
	(a, b) = (0, 0)
	i = 0
	while x != 0:
		i += 1
		if i % 2 == 1:
			x -= 2 ** (i - 1)
			if x < 0:
				x += 2 ** (i - 1)
				a += x
				x = 0
			else:
				a += 2 ** (i - 1)
		if i % 2 == 0:
			x -= 2 ** (i - 1)
			if x < 0:
				x += 2 ** (i - 1)
				b += x
				x = 0
			else:
				b += 2 ** (i - 1)
	return odd(a) + even(b)
print((ans(r) - ans(l - 1)) % 1000000007)


mod = 10 ** 9 + 7

def sum(r):
	cnt = 0
	p = 1
	pr = 0
	res = 0
	t = 1
	ne_ch = 2
	ne_nch = 1
	while cnt + p <= r:
		if t == 1:
			a_1 = ne_nch
			ne_nch += 2 * p
		else:
			a_1 = ne_ch
			ne_ch += 2 * p
		a_n = a_1 + 2 * (p - 1)
		res = (res + (a_1 + a_n) * p // 2) % mod
		cnt += p
		p *= 2
		t ^= 1
	if t == 1:
		a_1 = ne_nch
	else:
		a_1 = ne_ch
	n = r - cnt
	a_n = a_1 + (n - 1) * 2
	res = (res + (a_1 + a_n) * n // 2) % mod
	return res
(l, r) = map(int, input().split())
print((mod * 10 + sum(r) - sum(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)


from sys import stdin
input = stdin.readline

def f(x, c=0):
	n = x
	while n != 0:
		c += 1
		n //= 2
	cnt1 = 0
	cnt2 = 0
	for i in range(c - 1):
		if i % 2 == 0:
			cnt1 += 1 << i
		else:
			cnt2 += 1 << i
	if c % 2 == 1:
		cnt1 += x - cnt1 - cnt2
	else:
		cnt2 += x - cnt1 - cnt2
	return (cnt2 + 1) * cnt2 + cnt1 ** 2
(l, r) = map(int, input().split())
mod = 1000000007
print((f(r) - f(l - 1)) % mod)


from math import log
m = 1000000007
(l, r) = input().split()
l = int(l)
r = int(r)
l -= 1
if l == 0:
	ls = 0
else:
	k = int(log(l, 2))
	if k % 2 == 1:
		o = (2 ** (k + 1) - 1) // 3
		e = l - o
		os = o * o
		es = e * e + e
		ls = os + es
	else:
		e = 2 * (2 ** k - 1) // 3
		o = l - e
		os = o * o
		es = e * e + e
		ls = os + es
l = r
if l >= 1:
	k = int(log(l, 2))
	if k % 2 == 1:
		o = (2 ** (k + 1) - 1) // 3
		e = l - o
		os = o * o
		es = e * e + e
		us = os + es
	else:
		e = 2 * (2 ** k - 1) // 3
		o = l - e
		os = o * o
		es = e * e + e
		us = os + es
ans = us - ls
ans = ans % m
print(int(ans))


import sys
input = sys.stdin.readline
(l, r) = 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)


(l, r) = tuple(map(int, input().strip().split()))
import math
j = math.floor(math.log(l, 2))
jj = math.floor(math.log(r, 2))

def osum(k):
	return k ** 2 % 1000000007

def esum(k):
	return (k ** 2 + k) % 1000000007
o = 0
e = 0
s = 1
pos = 0
t = 1
while pos < l:
	if t:
		o = o + s
		pos = pos + s
	else:
		e = e + s
		pos = pos + s
	s = 2 * s
	t = 1 - t
if t == 0:
	even = e + 1
	summ = 0
	o = o - s // 2
	pos = pos - s // 2
	odd = o + (l - pos)
	t = 1
	s = s // 2
	while pos < r:
		if t:
			o = o + s
			pos = pos + s
		else:
			e = e + s
			pos = pos + s
		s = 2 * s
		t = 1 - t
	if t == 0:
		even1 = e
		o = o - s // 2
		pos = pos - s // 2
		odd1 = o + (r - pos)
		print((osum(odd1) - osum(odd - 1) + esum(even1) - esum(even - 1)) % 1000000007)
	else:
		odd1 = o
		e = e - s // 2
		pos = pos - s // 2
		even1 = e + (r - pos)
		print((osum(odd1) - osum(odd - 1) + esum(even1) - esum(even - 1)) % 1000000007)
else:
	odd = o + 1
	summ = 0
	e = e - s // 2
	pos = pos - s // 2
	even = e + (l - pos)
	t = 0
	s = s // 2
	while pos < r:
		if t:
			o = o + s
			pos = pos + s
		else:
			e = e + s
			pos = pos + s
		s = 2 * s
		t = 1 - t
	if t == 0:
		even1 = e
		o = o - s // 2
		pos = pos - s // 2
		odd1 = o + (r - pos)
		print((osum(odd1) - osum(odd - 1) + esum(even1) - esum(even - 1)) % 1000000007)
	else:
		odd1 = o
		e = e - s // 2
		pos = pos - s // 2
		even1 = e + (r - pos)
		print((osum(odd1) - osum(odd - 1) + esum(even1) - esum(even - 1)) % 1000000007)


def func(x):
	ansodd = 0
	ansev = 0
	stp = 1
	i = True
	while x > 0:
		if i:
			ansodd += min(x, stp)
		else:
			ansev += min(x, stp)
		i = not i
		x -= stp
		stp *= 2
	return ansodd ** 2 + (ansev + 1) * ansev
(L, R) = map(int, input().split())
print((func(R) - func(L - 1)) % 1000000007)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math

def sum(x):
	even = 0
	odd = 0
	for i in range(100):
		if x <= 0:
			break
		power = 2 ** i
		if i % 2 == 0:
			odd += min(power, x)
		else:
			even += min(power, x)
		x -= power
	s = even * (even + 1) % MOD
	s += odd * odd % MOD
	s %= MOD
	return s

def solve():
	(l, r) = int_array()
	ans = sum(r) - sum(l - 1) + MOD
	ans %= MOD
	print(ans)
for _ in range(1):
	solve()


a = [i * 2 + 1 for i in range(1000)]
b = [i * 2 + 2 for i in range(1000)]
x = [a, b]
y = [0, 0]
s = [0, 1]
t = [0, 1]
for i in range(2, 70):
	s.append(s[i - 1] + s[i - 2] * 2)
	t.append(2 * t[i - 1] + int(i % 2 == 1))
s = s[2:]
(l, r) = map(int, input().split())
l -= 1
k = 0
i = 0
while True:
	if k + s[i] > l:
		break
	k += s[i]
	i += 1
c = l - k
if c > t[i] + 1:
	c -= t[i] + 1
	c = t[i] - c + 1
c -= 1
c = c * (c + 1) // 2
k = 0
i = 0
while True:
	if k + s[i] > r:
		break
	k += s[i]
	i += 1
d = r - k
if d > t[i] + 1:
	d -= t[i] + 1
	d = t[i] - d + 1
d -= 1
d = d * (d + 1) // 2
l += 1
x = ((l + r) * (r - l + 1) // 2 + d - c) % (10 ** 9 + 7)
print(x)


import math
MOD = 10 ** 9 + 7
(l, r) = map(int, input().split())

def calc(r):
	cnt_o = 0
	cnt_e = 0
	x = 0
	while cnt_o + cnt_e + (1 << x) <= r:
		if not x & 1:
			cnt_o += 1 << x
		else:
			cnt_e += 1 << x
		x += 1
	if x & 1:
		cnt_e = r - cnt_o
	else:
		cnt_o = r - cnt_e
	return cnt_o ** 2 + (cnt_e + 1) * cnt_e
print((calc(r) - calc(l - 1)) % MOD)


MOD = 1000000007
MODI4 = 250000002

def fsum(l):
	if l == 0:
		return 0
	(p, last_e, last_o, ret, cnt) = (2, 0, 1, 1, 0)
	l -= 1
	while l > 0:
		if cnt % 2:
			curr_o = last_o + 2 * min(l, p)
			ret = (ret - (last_o + 1) ** 2 * MODI4 + (curr_o + 1) ** 2 * MODI4) % MOD
			last_o = curr_o
		else:
			curr_e = last_e + 2 * min(l, p)
			ret = (ret - last_e * (last_e + 2) * MODI4 + curr_e * (curr_e + 2) * MODI4) % MOD
			last_e = curr_e
		l -= p
		p *= 2
		cnt += 1
	return ret
(l, r) = map(int, input().split())
print((fsum(r) - fsum(l - 1)) % MOD)


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

def odd_sum(n):
	return even_sum(n) - n

def sum(n):
	cnt = 0
	m = n
	while m != 0:
		cnt += 1
		m >>= 1
	if cnt % 2 == 0:
		odds = (4 ** (cnt // 2) - 1) // 3
		evens = n - odds
	else:
		evens = 2 * (4 ** (cnt // 2) - 1) // 3
		odds = n - evens
	return even_sum(evens) + odd_sum(odds)
(l, r) = map(int, input().split())
print((sum(r) - sum(l - 1)) % (10 ** 9 + 7))


from math import *
R = lambda : map(int, input().split())
(l, r) = R()

def f(n):
	if n <= 0:
		return 0
	m = ceil(log2(n + 1))
	if m % 2:
		b = max(0, 2 * (4 ** (m // 2) - 1) // 3)
		a = n - b
	else:
		a = max(0, (4 ** (m // 2) - 1) // 3)
		b = n - a
	return a * a + b * (b + 1)
print((f(r) - f(l - 1)) % (10 ** 9 + 7))


import math

def calc(n):
	n = n + 1
	pos = int(math.log2(n))
	n1 = (pos + 1) // 2
	n2 = pos - n1
	a = (4 ** n1 - 1) // 3
	b = 2 * (4 ** n2 - 1) // 3
	if n1 == n2:
		a += n - 2 ** pos
	else:
		b += n - 2 ** pos
	a = a ** 2
	b = b * (b + 1)
	return a + b
(a, b) = list(map(int, input().split()))
print(int(calc(b) - calc(a - 1)) % 1000000007)


(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)


m = int(1000000000.0 + 7)

def f(x):
	l = len(bin(x)) - 3
	if l & 1:
		(o, e) = (l, l - 1)
	else:
		(o, e) = (l - 1, l)
	o = (pow(2, o + 1, m) - 1) % m
	e = (pow(2, e + 1, m) - 2) % m
	o = o * 333333336 % m
	e = e * 333333336 % m
	d = x - (1 << l) + 1
	d %= m
	if l & 1:
		e += d
	else:
		o += d
	res = o * o % m
	res += e * (e + 1) % m
	res %= m
	return res
(l, r) = map(int, input().split())
print((f(r) - f(l - 1)) % m)


import math
(l, r) = map(int, input().split())

def sumn(n):
	if n == 0:
		return 0
	k = int(math.log(n, 2))
	if k % 2 != 0:
		no = 0
		for i in range(1, k + 1, 2):
			no += 2 ** (i - 1)
		ne = n - no
	else:
		ne = 0
		for i in range(2, k + 1, 2):
			ne += 2 ** (i - 1)
		no = n - ne
	return no * no + ne * (ne + 1)
print((sumn(r) - sumn(l - 1)) % 1000000007)


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

def cnts(n):
	take = 1
	set_num = 1
	cnt = [0, 0]
	while take < n:
		cnt[set_num] += take
		n -= take
		take <<= 1
		set_num ^= 1
	cnt[set_num] += n
	return cnt

def f(n):
	(e, o) = cnts(n)
	return e * (e + 1) + o * o
print((f(r) - f(l - 1)) % int(1000000000.0 + 7))


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) = map(int, input().split())
ans = cs(R)
if L > 1:
	ans -= cs(L - 1)
ans %= MOD
print(ans)


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

def retrieve(level, fr, to):
	if level % 2 == 1:
		start = 1
		jump = 2
		for i in range((level - 1) // 2):
			start += jump
			jump *= 4
		a = start + 2 * fr
		n = to - fr + 1
		return n * (n + a - 1)
	else:
		start = 2
		jump = 4
		for i in range((level - 2) // 2):
			start += jump
			jump *= 4
		a = start + 2 * fr
		n = to - fr + 1
		return n * (n + a - 1)
level = 1
ll = 1
rr = 1
while True:
	if ll <= l and l <= rr:
		if r <= rr:
			print(retrieve(level, l - ll, r - ll) % 1000000007)
			exit()
		else:
			sum = retrieve(level, l - ll, rr - ll)
			level += 1
			ll *= 2
			rr = (rr + 1) * 2 - 1
			while True:
				if r <= rr:
					sum += retrieve(level, 0, r - ll)
					print(sum % 1000000007)
					exit()
				else:
					sum += retrieve(level, 0, rr - ll)
				level += 1
				ll *= 2
				rr = (rr + 1) * 2 - 1
	level += 1
	ll *= 2
	rr = (rr + 1) * 2 - 1


def solve(pref):
	res = 0
	p = [1, 2]
	need = 0
	now = 1
	while pref - now >= 0:
		pref -= now
		res += (p[need] + p[need] + 2 * now - 2) * now // 2
		res %= 1000000007
		p[need] += 2 * now
		now *= 2
		need ^= 1
	res += (p[need] + p[need] + 2 * pref - 2) * pref // 2
	res %= 1000000007
	return res
(l, r) = map(int, input().split())
print((solve(r) - solve(l - 1) + 1000000007) % 1000000007)


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)


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def def_value():
	return 0

def mul(a, b, c=mod):
	return a % c * (b % c) % c

def sum(n):
	if n == 0:
		return 0
	else:
		x = floor(log2(n + 1))
		xx = pow(2, x) - 1
		o = (x + 1) // 2
		e = x // 2
		odd = pow(4, o) - 1
		even = pow(4, e) - 1
		odd //= 3
		even //= 3
		even *= 2
		if xx < n:
			if x % 2 == 0:
				odd = odd + (n - xx)
			else:
				even = even + (n - xx)
		ans1 = mul(odd, odd)
		ans2 = mul(even, even + 1)
		ans = (ans1 + ans2) % mod
		return ans
(l, r) = mp()
rr = sum(r)
ll = sum(l - 1)
a = (rr + mod - ll) % mod
print(a)


mod = int(1000000000.0) + 7

def mult(a, b):
	return a % mod * (b % mod) % mod

def f(x):
	flag = False
	qtdO = 0
	qtdE = 0
	power = 1
	cnt = 0
	while x > 0:
		if cnt % 2 == 1:
			qtdE += min(power, x)
		else:
			qtdO += min(power, x)
		x -= min(power, x)
		power = power << 1
		cnt = (cnt + 1) % 2
	sO = mult(qtdO, qtdO)
	sE = mult(qtdE, qtdE + 1)
	return (sO + sE) % mod
(l, r) = [int(i) for i in input().split()]
if l == 1:
	print(f(r) % mod)
else:
	print((f(r) - f(l - 1) + mod) % mod)


import sys

def getSumsOddEvenPotenciesTwo(p):
	i = 0
	j = 0
	for e in range(0, p):
		if e % 2 == 0:
			i += pow(2, e)
		else:
			j += pow(2, e)
	return (i, j)

def getNearPotencyTwo(n):
	c = 0
	while n > 0:
		n = n >> 1
		c += 1
	return c - 1

def getSumSerie(n):
	if n == 0:
		return 0
	p = getNearPotencyTwo(n)
	(i, j) = getSumsOddEvenPotenciesTwo(p)
	if p % 2 == 0:
		i += n - (pow(2, p) - 1)
	else:
		j += n - (pow(2, p) - 1)
	return 2 * i * i // 2 + 2 * (j + 1) * j // 2
line = sys.stdin.readline().split()
l = int(line[0])
r = int(line[1])
s = (getSumSerie(r) - getSumSerie(l - 1)) % 1000000007
print('%d' % s)


def sum1n(n):
	return n * (n + 1) // 2

def suma(a, l):
	b = a + 2 * (l - 1)
	return (a + b) * l // 2

def cal(n):
	if n == 0:
		return 0
	if n == 1:
		return 1
	res = 1
	chan = 0
	le = 1
	for i in range(2, 100):
		if pow(2, i) - 1 <= n:
			if i % 2 == 0:
				res += suma(chan + 2, pow(2, i - 1))
				chan = chan + 2 + 2 * (pow(2, i - 1) - 1)
			else:
				res += suma(le + 2, pow(2, i - 1))
				le = le + 2 + 2 * (pow(2, i - 1) - 1)
		else:
			break
	pw2 = pow(2, i - 1) - 1
	if i % 2 == 0:
		x = chan
	else:
		x = le
	if n == pw2:
		return res
	else:
		return res + suma(x + 2, n - pw2)
(a, b) = map(int, input().split())
print((cal(b) - cal(a - 1)) % 1000000007)


def f(p):
	l1 = len(bin(p)) - 2
	(e, o) = (0, 0)
	for i in range(l1 - 1):
		if i % 2:
			e += 1 << i
		else:
			o += 1 << i
	if l1 % 2:
		o += p - (e + o)
	else:
		e += p - (e + o)
	s = e ** 2 + e
	s += o ** 2
	return s
M = 10 ** 9 + 7
R = lambda : map(int, input().split())
(l, r) = R()
print((f(r) - f(l - 1)) % M)


from math import *
INF = int(pow(10, 9)) + 7

def sum(n):
	if n == 0:
		return 0
	lg = trunc(log2(n))
	ed = 0
	ne = 0
	for i in range(0, lg):
		if i % 2 == 1:
			ed += int(pow(2, i))
		else:
			ne += int(pow(2, i))
	sm = n - ed - ne
	if lg % 2 == 0:
		ne += sm
	else:
		ed += sm
	ans = ((ed + 1) * ed + (ne - 1) * ne + ne) % INF
	return ans
(l, r) = input().split()
l = int(l)
r = int(r)
print((INF + sum(r) - sum(l - 1)) % INF)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(l, r) = map(int, input().split())
t = 1
c = 1
odd = 0
even = 0
su = 1
while su <= r:
	if c % 2 == 1:
		odd += t
	else:
		even += t
	t *= 2
	c += 1
	su += t
if odd + even < r:
	if c % 2 == 1:
		odd += t - su + r
	else:
		even += t - su + r
ans = even * (even + 1) % 1000000007 + odd * odd % 1000000007
l -= 1
odd = 0
even = 0
t = 1
c = 1
su = 1
while su <= l:
	if c % 2 == 1:
		odd += t
	else:
		even += t
	t *= 2
	c += 1
	su += t
if odd + even < l:
	if c % 2 == 1:
		odd += t - su + l
	else:
		even += t - su + l
ans -= even * (even + 1) % 1000000007 + odd * odd % 1000000007
print(ans % 1000000007)


def f(n):
	x = 0
	y = 0
	k = 0
	for i in range(66):
		z = 1 << i
		if n - z < 0:
			break
		if i % 2 == 0:
			x += z
		else:
			y += z
		n -= z
		k = i + 1
	if k % 2 == 0:
		x += n
	else:
		y += n
	sum1 = x ** 2 % m
	sum1 = sum1 + y * (y + 1) % m
	return sum1 % m
m = 1000000007
(l, r) = map(int, input().split())
t1 = f(l - 1)
t2 = f(r)
print((t2 - t1 + m) % m)


def f(n):
	res = 0
	if n == 0:
		return 0
	od = 0
	ev = 0
	k = n.bit_length()
	t = k - 1
	ev = t // 2
	od = -(-t // 2)
	o = (4 ** od - 1) // 3
	e = 2 * (4 ** ev - 1) // 3
	r = n - 2 ** t + 1
	if ev == od:
		o += r
	else:
		e += r
	res += o ** 2
	res += e * (e + 1)
	return res
mod = 10 ** 9 + 7
(l, r) = map(int, input().split())
print((f(r) - f(l - 1)) % mod)


mod = 1000000007

def getSum(i):
	o = True
	s = 0
	np = 1
	bl = 1
	br = 2
	while i:
		t = min(i, np)
		if o:
			base = bl
		else:
			base = br
		i -= t
		sp = t * t % mod
		sp = (sp + (base - 1) % mod * t % mod) % mod
		s = (s + sp) % mod
		if o:
			bl += np * 2
		else:
			br += np * 2
		np *= 2
		o = not o
	return s
(l, r) = [int(x) for x in input().split()]
l -= 1
print((getSum(r) - getSum(l) + mod) % mod)


M = int(10 ** 9 + 7)

def sum_odd(a):
	ans = a
	ans *= a
	ans %= M
	return ans

def sum_even(a):
	ans = a
	ans *= a + 1
	ans %= M
	return ans

def f(n):
	if n == 0:
		return 0
	tot_idx = 0
	last_odd = 0
	last_eve = 0
	cur = 1
	which = 0
	S = 0
	while tot_idx < n:
		new_tot = tot_idx + cur
		which += 1
		which %= 2
		if new_tot <= n:
			if which == 0:
				S += sum_even(cur + last_eve)
				S -= sum_even(last_eve)
				S += M
				S %= M
				last_eve += cur
			else:
				S += sum_odd(cur + last_odd)
				S -= sum_odd(last_odd)
				S += M
				S %= M
				last_odd += cur
			tot_idx = new_tot
			if tot_idx == n:
				return S
		else:
			get = n - tot_idx
			if which == 0:
				S += sum_even(get + last_eve)
				S -= sum_even(last_eve)
				S += M
				S %= M
			else:
				S += sum_odd(get + last_odd)
				S -= sum_odd(last_odd)
				S += M
				S %= M
			return S
		cur *= 2
[l, r] = [int(i) for i in input().split()]
ans = f(r)
ans -= f(l - 1)
ans += M
ans %= M
print(ans)


def cout(x):
	ch = nec = i = 0
	while x > 0:
		if i % 2 == 0:
			nec += min(x, 2 ** i)
		else:
			ch += min(x, 2 ** i)
		x -= min(x, 2 ** i)
		i += 1
	n_ch = ch * 2
	n_nec = 2 * nec - 1
	return ch * (n_ch + 2) // 2 + nec * (n_nec + 1) // 2
(l, r) = [int(x) for x in input().split()]
print((cout(r) - cout(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)


(l, r) = map(int, input().split())
mod = 10 ** 9 + 7

def f(x):
	if x == 0:
		return 0
	res = 1
	cnt = 2
	f = 1
	b_s = 2
	e_s = 4
	b_f = 3
	e_f = 9
	x -= 1
	while x > 0:
		if f:
			res += cnt * (b_s + e_s) // 2
			b_s = e_s + 2
			e_s = e_s + 2 * (4 * cnt)
		else:
			res += cnt * (b_f + e_f) // 2
			b_f = e_f + 2
			e_f = e_f + 2 * (4 * cnt)
		x -= cnt
		if x < 0:
			if f:
				b_s -= 2
				res -= abs(x) * (b_s + b_s - abs(x + 1) * 2) // 2
			else:
				b_f -= 2
				res -= abs(x) * (b_f + b_f - abs(x + 1) * 2) // 2
		cnt *= 2
		f = 1 - f
	return res
print((f(r) - f(l - 1)) % mod)


s = 0
(l, r) = map(int, input().split())
x1 = 1
x2 = 2
i = 1
turn = 1
multiplier = 1
while i + multiplier < l:
	if turn == 0:
		i += multiplier
		x2 = x2 + multiplier * 2
		multiplier = multiplier * 2
		turn = 1
	else:
		i += multiplier
		x1 = x1 + multiplier * 2
		multiplier *= 2
		turn = 0
remaining = multiplier
flag = 0
if i != l:
	remaining = remaining - (l - i)
	if turn == 1:
		x1 += (l - i) * 2
	else:
		x2 += (l - i) * 2
if r - l + 1 >= remaining:
	if turn == 1:
		s += remaining * (x1 + (remaining - 1))
		l += remaining
		turn = 0
		x1 = x1 + remaining * 2
	else:
		s += remaining * (x2 + (remaining - 1))
		l += remaining
		turn = 1
		x2 = x2 + remaining * 2
	multiplier *= 2
else:
	flag = 1
	remaining = r - l + 1
	if turn == 1:
		s += remaining * (x1 + (remaining - 1))
	else:
		s += remaining * (x2 + (remaining - 1))
if flag == 1:
	print(s % (10 ** 9 + 7))
else:
	while l + multiplier <= r:
		if turn == 0:
			l += multiplier
			s += int(multiplier * (x2 + (multiplier - 1)))
			x2 = x2 + multiplier * 2
			multiplier = multiplier * 2
			turn = 1
		else:
			l += multiplier
			s += int(multiplier * (x1 + (multiplier - 1)))
			x1 = x1 + multiplier * 2
			multiplier *= 2
			turn = 0
	if l <= r:
		remaining = r - l + 1
		if turn == 1:
			s += int(remaining * (x1 + (remaining - 1)))
			l += remaining
		else:
			s += int(remaining * (x2 + (remaining - 1)))
			l += remaining
	print(s % (10 ** 9 + 7))


from math import log
(l, r) = map(int, input().split())
MOD = 10 ** 9 + 7

def odd(n):
	return n ** 2 % MOD

def even(n):
	return n * (n + 1) % MOD

def foo(n):
	if n == 0:
		return 0
	m = int(log(n, 2))
	if m % 2 == 1:
		o = (4 ** ((m - 1) // 2 + 1) - 1) // (4 - 1)
		e = n - o
	else:
		e = 2 * (4 ** ((m - 2) // 2 + 1) - 1) // (4 - 1)
		o = n - e
	return odd(o) + even(e)
print((foo(r) - foo(l - 1)) % MOD)


import sys
(l, r) = list(map(int, sys.stdin.readline().strip().split()))

def sumton(n):
	if n == 0:
		return 0
	i = 0
	n2 = n
	while n > 1:
		n = n // 2
		i = i + 1
	if i % 2 == 1:
		odd = (2 ** (i + 1) - 1) // 3
		even = n2 - odd
	else:
		even = 2 * (2 ** i - 1) // 3
		odd = n2 - even
	return even * (even + 1) + odd ** 2
print((sumton(r) - sumton(l - 1)) % 1000000007)


mod = 10 ** 9 + 7

def solve(x):
	if x == 0:
		return 0
	for K in range(100):
		if 2 ** K <= x < 2 ** (K + 1):
			break
	score = 0
	if K % 2 == 0:
		last1 = 1
		for n in range(K // 2):
			last1 += 2 * 2 ** (2 * n)
		last1 += 2 * (x - 2 ** K)
		last2 = 0
		for n in range(K // 2):
			last2 += 2 * 2 ** (2 * n + 1)
	else:
		last2 = 2
		for n in range(K // 2):
			last2 += 2 * 2 ** (2 * n + 1)
		last2 += 2 * (x - 2 ** K)
		last1 = -1
		for n in range(K // 2 + 1):
			last1 += 2 * 2 ** (2 * n)
	score = (last1 + 1) ** 2 // 4 % mod + (last2 + 2) * last2 // 4 % mod
	score %= mod
	return score
(L, R) = map(int, input().split())
a = solve(L - 1)
b = solve(R)
if b < a:
	b += mod
ans = (b - a) % mod
print(ans)


P = 10 ** 9 + 7

def even_sum(k):
	return k % P * ((k + 1) % P) % P

def odd_sum(k):
	return k % P * (k % P) % P

def find_sum(n):
	d = 1
	i = 0
	o = 1
	evens = 0
	odds = 0
	while True:
		i += d
		if o:
			odds += d
		else:
			evens += d
		if i >= n:
			if o:
				odds -= i - n
			else:
				evens -= i - n
			break
		o ^= 1
		d <<= 1
	return (odd_sum(odds) + even_sum(evens)) % P
(l, r) = list(map(int, input().strip().split()))
l = find_sum(l - 1)
r = find_sum(r)
v = r - l
print(v % P)


(l, r) = input().split()
l = int(l)
r = int(r)
a1 = 1
a2 = 2
curr = 1
mod = 1000000007
i = 0
l -= 1
ans1 = 0
ans2 = 0
while l >= curr:
	if i % 2 == 1:
		ans1 = ans1 + curr * (a2 + (curr - 1))
		a2 = a2 + curr * 2
	else:
		ans1 = ans1 + curr * (a1 + (curr - 1))
		a1 = a1 + curr * 2
	ans1 = int(ans1 % mod)
	i += 1
	l -= curr
	curr *= 2
if l != 0:
	if i % 2 == 1:
		ans1 = ans1 + l * (a2 + (l - 1))
	else:
		ans1 = ans1 + l * (a1 + (l - 1))
	ans1 = int(ans1 % mod)
i = 0
curr = 1
a1 = 1
a2 = 2
while r >= curr:
	if i % 2 == 1:
		ans2 = ans2 + curr * (a2 + (curr - 1))
		a2 = a2 + curr * 2
	else:
		ans2 = ans2 + curr * (a1 + (curr - 1))
		a1 = a1 + curr * 2
	ans2 = int(ans2 % mod)
	i += 1
	r -= curr
	curr *= 2
if r != 0:
	if i % 2 == 1:
		ans2 = ans2 + r * (a2 + (r - 1))
	else:
		ans2 = ans2 + r * (a1 + (r - 1))
	ans2 = int(ans2 % mod)
print(int((ans2 - ans1) % mod))


def getTerm(idx):
	n = -1
	copy = idx
	while copy > 0:
		copy = copy // 2
		n = n + 1
	m = n
	temp = 1
	while m > 0:
		temp = temp * 2
		m = m - 1
	diff = idx - temp
	return (n, diff)

def getSum(expo, addit, powers):
	if expo % 2 == 0:
		tempo = 0
		ctr = 0
		while ctr < expo:
			tempo = tempo + powers[ctr]
			ctr = ctr + 2
		start = tempo * 2 + 1
		extra = addit * (start + addit - 1)
		return extra
	else:
		tempo = 0
		ctr = 1
		while ctr < expo:
			tempo = tempo + powers[ctr]
			ctr = ctr + 2
		start = tempo * 2 + 2
		extra = addit * (start + addit - 1)
		return extra

def main():
	(l, r) = map(int, input().split())
	summ = 0
	(lnewE, lnewA) = getTerm(l)
	(rnewE, rnewA) = getTerm(r)
	powers = []
	powers.append(1)
	for i in range(1, 60):
		powers.append(powers[i - 1] * 2)
	differ = rnewE - lnewE
	if differ == 0:
		summ = getSum(rnewE, rnewA + 1, powers) - getSum(lnewE, lnewA, powers)
		summ = summ % 1000000007
		print(summ)
		return 0
	summ = summ + getSum(lnewE, powers[lnewE], powers) - getSum(lnewE, lnewA, powers)
	differ = differ - 1
	lnewE = lnewE + 1
	while differ >= 0:
		if differ == 0:
			summ = summ + getSum(rnewE, rnewA + 1, powers)
			break
		summ = summ + getSum(lnewE, powers[lnewE], powers)
		lnewE = lnewE + 1
		differ = differ - 1
	summ = summ % 1000000007
	print(summ)
main()


def Log(a):
	cnt = 0
	while a > 0:
		cnt += 1
		a = a >> 1
	return cnt - 1

def quickpow(p, q):
	ans = 1
	while q > 0:
		if q % 2 == 1:
			ans = ans * p
		p = p * p
		q //= 2
	return ans

def cal(a):
	if a == 0:
		return 0
	log2 = Log(a)
	sum_odd = 0
	sum_even = 0
	if log2 % 2 == 0:
		sum_odd = (quickpow(2, log2) - 1) // 3 + a - quickpow(2, log2) + 1
		sum_even = 2 * (quickpow(2, log2) - 1) // 3
	else:
		sum_odd = (quickpow(2, log2 + 1) - 1) // 3
		sum_even = 2 * (quickpow(2, log2 - 1) - 1) // 3 + a - quickpow(2, log2) + 1
	ans = 0
	ans = (1 + 2 * sum_odd - 1) * sum_odd // 2
	ans += (2 + 2 * sum_even) * sum_even // 2
	return ans
mod = int(1000000007)
(le, ri) = map(int, input().split())
ans = (cal(ri) - cal(le - 1) + mod) % mod
print(ans)


def su(n):
	return n * (n + 1) % b

def suo(n):
	return (n * (n + 1) - n) % b

def f(k):
	i = 1
	l = 1
	s = 0
	c = [0, 0]
	while s + l <= k:
		s += l
		c[i % 2] += l
		i += 1
		l *= 2
	c[i % 2] += k - s
	return (su(c[0]) + suo(c[1])) % b
b = 1000000007
(l, r) = map(int, input().split())
aa = f(r) - f(l - 1)
print((aa + b) % b)


(l, r) = map(int, input().split())
l = bin(l)
r = bin(r)
br = len(l[2:])
(es, os) = (0, 0)

def f(l):
	l = bin(l)
	br = len(l[2:])
	es = 0
	if br % 2 == 0:
		br = br // 2
		x = 2 * (4 ** (br - 1) - 1) // 3
		x = x + int('0' + l[3:], 2)
		es = 2 * x + 2
	else:
		br = br // 2 + 1
		x = 1 * (4 ** (br - 1) - 1) // 3
		x = x + int('0' + l[3:], 2)
		es = 2 * x + 1
	return es
if br % 2 == 0:
	br = br // 2
	x = 2 * (4 ** (br - 1) - 1) // 3
	x = x + int('0' + l[3:], 2)
	es = 2 * x + 2
	os = f(int('1' + '0' * (2 * br), 2))
else:
	br = br // 2 + 1
	x = 1 * (4 ** (br - 1) - 1) // 3
	x = x + int('0' + l[3:], 2)
	os = 2 * x + 1
	es = f(int('1' + '0' * (2 * (br - 1) + 1), 2))
br = len(r[2:])
(el, ol) = (0, 0)
if br % 2 == 0:
	br = br // 2
	x = 2 * (4 ** (br - 1) - 1) // 3
	x = x + int('0' + r[3:], 2)
	el = 2 * x + 2
	ol = f(int('0' + '1' * (2 * br - 1), 2))
else:
	br = br // 2 + 1
	x = 1 * (4 ** (br - 1) - 1) // 3
	x = x + int('0' + r[3:], 2)
	ol = 2 * x + 1
	el = f(int('0' + '1' * (2 * (br - 1)), 2))
h = 1000000007
r = ((el - es) // 2 + 1) * ((el + es) // 2) + ((ol - os) // 2 + 1) * ((ol + os) // 2)
r = r % h
print(r)


from sys import stdin

def readLine():
	return stdin.readline().strip()

def readInt():
	return int(readLine())

def readInts():
	return list(map(int, readLine().split()))
MOD = int(1000000000.0 + 7)

def getOddSum(a, b):
	return b * (b + 1) - b - (a * (a + 1) - a)

def getEvenSum(a, b):
	return b * (b + 1) - a * (a + 1)

def getSum(isOdd, a, b):
	return getOddSum(a, b) if isOdd else getEvenSum(a, b)
isInside = lambda x, a, b: a <= x <= b
getIdx = lambda n: 0 if n == 0 else getIdx(n >> 2) + n
getIndex = lambda n: getIdx(n >> 2)
mod = lambda n: n % MOD
modSum = lambda a, b: mod(mod(a) + mod(b))
modSub = lambda a, b: mod(mod(a) - mod(b))

def solve(L, R):
	isOdd = 1
	currentPos = [2, 1]
	p = 1
	s = 0
	subtract = 0
	res = 0
	while not isInside(L, p, (p << 1) - 1):
		currentPos[isOdd] <<= 2
		p <<= 1
		isOdd ^= 1
	if p < L:
		s = getSum(isOdd, getIndex(currentPos[isOdd]), getIndex(currentPos[isOdd]) + (L - p))
		subtract = modSum(subtract, s)
	while p <= R:
		s = getSum(isOdd, getIndex(currentPos[isOdd]), getIndex(currentPos[isOdd]) + currentPos[isOdd])
		currentPos[isOdd] <<= 2
		res = modSum(res, s)
		p <<= 1
		isOdd ^= 1
	if R < p - 1:
		p >>= 1
		isOdd ^= 1
		currentPos[isOdd] >>= 2
		s = getSum(isOdd, getIndex(currentPos[isOdd]) + (R - p + 1), getIndex(currentPos[isOdd]) + currentPos[isOdd])
		subtract = modSum(subtract, s)
	return modSub(res, subtract)

def main():
	global MOD
	(L, R) = readInts()
	print(solve(L, R))
main()


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 f(n):
	odd = 0
	even = 0
	turn = 1
	cur = 1
	while n:
		taken = min(n, cur)
		n -= taken
		if turn:
			odd += taken
		else:
			even += taken
		cur *= 2
		turn = 1 - turn
	return odd * (2 + (odd - 1) * 2) // 2 + even * (4 + (even - 1) * 2) // 2
(a, b) = [int(i) for i in input().split()]
print((f(b) - f(a - 1)) % (10 ** 9 + 7))


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))


from math import *
mod = int(1000000000.0 + 7)

def odd_sum(x):
	x %= mod
	x *= x
	return x % mod

def even_sum(x):
	x %= mod
	x = x ** 2 + x
	return x % mod

def p_sum(x):
	if x == 0:
		return 0
	l = int(log2(x))
	c = [0] * 2
	for i in range(l):
		c[i % 2] += 1 << i
	sisa = x - (1 << l) + 1
	c[l % 2] += sisa
	s = odd_sum(c[0]) + even_sum(c[1])
	s %= mod
	return s
(l, r) = map(int, input().split())
ans = p_sum(r) - p_sum(l - 1)
print(ans % mod)


(l, r) = map(int, input().split())
l = l - 1
m = bin(l)
n = bin(r)
q = len(m) - 3
j = len(n) - 3
k = 0
c = 0
flag = 1
for i in range(0, q):
	if i % 2 == 0:
		k = k + pow(2, i)
		flag = 0
	else:
		flag = 1
		c = c + pow(2, i)
x = pow(2, q) - 1
z = l - x
if flag == 1:
	k = k + z
else:
	c = c + z
odd1 = k * k
even1 = (c + 1) * c
sum1 = odd1 + even1
k = 0
c = 0
flag = 1
q = j
for i in range(0, q):
	if i % 2 == 0:
		k = k + pow(2, i)
		flag = 0
	else:
		flag = 1
		c = c + pow(2, i)
x = pow(2, q) - 1
z = r - x
if flag == 1:
	k = k + z
else:
	c = c + z
odd2 = k * k
even2 = (c + 1) * c
sum2 = odd2 + even2
t = (sum2 - sum1) % 1000000007
print(t)


MOD = 1000000007

def add(a, b):
	return (a + b) % MOD

def mult(a, b):
	return a * b % MOD

def odd(n):
	return mult(n, n)

def odd_ab(a, b):
	return add(odd(b), -odd(a - 1))

def even(n):
	return mult(n, add(n, 1))

def even_ab(a, b):
	return add(even(b), -even(a - 1))

def main():
	(L, R) = map(int, input().split())
	if R == 1:
		return 1
	l = 1
	r = 1
	ans = 0
	if L == 1:
		ans = 1
	(l_even, r_even) = (0, 0)
	(l_odd, r_odd) = (1, 1)
	i = -1
	while True:
		i += 1
		l *= 2
		r = 2 * l - 1
		if l > R:
			break
		size = r - l + 1
		ls = max(l, L)
		rr = min(r, R)
		if i % 2 == 1:
			l_odd = r_odd + 1
			r_odd = l_odd + size - 1
			if r >= L:
				a = l_odd + (ls - l)
				b = a + rr - ls
				ans = add(ans, odd_ab(a, b))
		else:
			l_even = r_even + 1
			r_even = l_even + size - 1
			if r >= L:
				a = l_even + (ls - l)
				b = a + rr - ls
				ans = add(ans, even_ab(a, b))
	return ans
print(main())


import math

def getValue(power):
	if power % 2 == 0:
		return 1 + 2 * (pow(4, power // 2) // 3)
	else:
		return 2 + 2 * (2 * (pow(4, power // 2) - 1) // 3)
mod = 1000000007
x = input().split(' ')
l = int(x[0])
r = int(x[1])
lp = int(math.ceil(math.log(l, 2)))
lower = pow(2, lp)
lowerVal = getValue(lp)
le = lp == int(math.floor(math.log(l, 2)))
up = int(math.floor(math.log(r, 2)))
upper = pow(2, up)
upperVal = getValue(up)
ue = up == int(math.ceil(math.log(r, 2)))
lVal = getValue(lp - 1)
rVal = getValue(up + 1)
if lowerVal % 2 == 0:
	startEven = lowerVal
	if le:
		startOdd = getValue(lp + 1)
	else:
		startOdd = lVal + 2 * (l - pow(2, lp - 1))
else:
	startOdd = lowerVal
	if le:
		startEven = getValue(lp + 1)
	else:
		startEven = lVal + 2 * (l - pow(2, lp - 1))
if upperVal % 2 == 0:
	endEven = upperVal + 2 * (r - upper)
	endOdd = getValue(up - 1) + 2 * (pow(2, up - 1) - 1)
else:
	endOdd = upperVal + 2 * (r - upper)
	endEven = getValue(up - 1) + 2 * (pow(2, up - 1) - 1)
sm = 0
p = (endOdd - startOdd) // 2 + 1
sm = (sm + int(p * (startOdd + p - 1)) % mod) % mod
p = (endEven - startEven) // 2 + 1
sm = (sm + int(p * (startEven + p - 1)) % mod) % mod
print(sm)


(l, r) = input().split()
l = int(l)
r = int(r)
MOD = 10 ** 9 + 7

def f(v):
	global 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)


M = 1000000007
import math
odd_start = 1
even_start = 2
count = 1
step_lst = []
for i in range(80):
	if i % 2 == 0:
		odd_end = odd_start + 2 * count - 2
		total = (odd_start + odd_end) // 2
		total *= count
		step_lst.append((odd_start, total))
		odd_start = odd_end + 2
	else:
		even_end = even_start + 2 * count - 2
		total = (even_start + even_end) // 2
		total *= count
		step_lst.append((even_start, total))
		even_start = even_end + 2
	count *= 2
(l, r) = map(int, input().split())
l_step = math.log2(l)
l_step = math.floor(l_step)
l_index = l - 2 ** l_step
r_step = math.log2(r)
r_step = math.floor(r_step)
r_index = r - 2 ** r_step
if l_step == r_step:
	start = step_lst[l_step][0] + l_index * 2
	end = step_lst[l_step][0] + r_index * 2
	count = r_index - l_index + 1
	total = count * ((end + start) // 2)
else:
	start = step_lst[l_step][0] + l_index * 2
	end = step_lst[l_step + 2][0] - 2
	count = (end - start) // 2 + 1
	total = count * ((end + start) // 2)
	for i in range(l_step + 1, r_step):
		total += step_lst[i][1]
	start = step_lst[r_step][0]
	end = step_lst[r_step][0] + r_index * 2
	count = (end - start) // 2 + 1
	inner_total = count * ((end + start) // 2)
	total += inner_total
total = int(total)
total = int(total % M)
print(total)


calc = [0] * 80
(l, r) = [int(x) for x in input().split(' ')]
pl = 0
pr = 0
deg = 1
p = 0
calc[0] = 1
calc[1] = 2
while deg <= 16000000000000000000:
	if deg & l:
		pl = p
	if deg & r:
		pr = p
	if p > 1:
		calc[p] = calc[p - 2] + (1 << p - 2) * 2
	deg *= 2
	p += 1
if pl == pr:
	killL = l - (1 << pl)
	killR = (1 << pr + 1) - r - 1
	ans = (calc[pl] + killL * 2 + calc[pl + 2] - 2 - killR * 2) * ((1 << pl) - killL - killR) // 2
	print(ans % 1000000007)
	exit(0)
killL = l - (1 << pl)
killR = (1 << pr + 1) - r - 1
ans = (calc[pl] + killL * 2 + calc[pl + 2] - 2) * ((1 << pl) - killL) // 2
ans += (calc[pr] - killR * 2 + calc[pr + 2] - 2) * ((1 << pr) - killR) // 2
for t in range(pl + 1, pr):
	ans += (calc[t] + calc[t + 2] - 2) * (1 << t) // 2
print(ans % 1000000007)


def read_ints():
	return list(map(int, input().split()))
M = 1000000007

def f(x):
	i = 0
	(cur_even, cur_odd) = (0, 0)
	while True:
		n = 2 ** i
		if i % 2 == 0:
			cur_odd = (cur_odd + min(x, n) % M) % M
		else:
			cur_even = (cur_even + min(x, n) % M) % M
		x -= n
		if x <= 0:
			break
		i += 1
	return cur_odd * cur_odd + cur_even * (1 + cur_even)

def solve(l, r):
	return (f(r) % M - f(l - 1) % M) % M
(l, r) = read_ints()
print(solve(l, r))


def cnt(n):
	m = 1
	k = [0, 0]
	i = 0
	while m <= n:
		k[i] += m
		n -= m
		m <<= 1
		i = 1 - i
	k[i] += n
	return k
modulo = 10 ** 9 + 7

def sm(n):
	k = cnt(n)
	return (k[1] * (k[1] + 1) + k[0] * k[0]) % modulo
(a, b) = map(int, input().split())
print((sm(b) - sm(a - 1)) % modulo)


from math import *

def cal(r):
	if r == 0:
		return 0
	fard = 0
	zog = 0
	for i in range(0, ceil(log2(r)), 2):
		fard += 2 ** i
	for i in range(1, ceil(log2(r)), 2):
		zog += 2 ** i
	if floor(log2(r)) % 2 == 0:
		fard -= 2 ** ceil(log2(r)) - 1 - r
	else:
		zog -= 2 ** ceil(log2(r)) - 1 - r
	sum = fard ** 2 + zog * (zog + 1)
	return sum % (10 ** 9 + 7)
(n, m) = map(int, input().split())
print((cal(m) - cal(n - 1)) % (10 ** 9 + 7))


__version__ = '1.1'
__date__ = '2019-04-19'
import sys
from math import log

def sum_odd(n, mod, inclusive=True):
	answer = pow(n, 2, mod)
	if not inclusive:
		return (answer - 2 * n + 1) % mod
	return answer

def sum_even(n, mod, inclusive=True):
	answer = pow(n, 2, mod) + n
	if not inclusive:
		return (answer - 2 * n) % mod
	return answer

def sum_geometric(a, r, n):
	if n == 1:
		return a
	return a * (pow(r, n) - 1) // (r - 1)

def sum_all_previous(lr, mod, inclusive=True):
	idx = int(log(lr, 2))
	n = (idx + 1) // 2
	if n < 1:
		if inclusive:
			return (0, 1, 3, 7)[lr]
		return (0, 1, 3, 7)[lr - 1]
	if idx % 2 == 1:
		odds = sum_geometric(1, 4, n)
		evens = lr - odds
		return sum_odd(odds, mod) + sum_even(evens, mod, inclusive)
	else:
		evens = sum_geometric(2, 4, n)
		odds = lr - evens
		return sum_even(evens, mod) + sum_odd(odds, mod, inclusive)
	return -1

def solve(l, r, mod):
	return (sum_all_previous(r, mod) - sum_all_previous(l, mod, inclusive=False)) % mod

def main(argv=None):
	(l, r) = map(int, input().split())
	mod = 1000000007
	print(solve(l, r, mod))
	return 0
STATUS = main()
sys.exit(STATUS)


(l, r) = (int(i) for i in input().split())
e = 0
o = 0
k = 1
s = 0
i = 0
mod = 1000000007
while s < l:
	s += k
	if i == 0:
		o += k
		i = 1
	else:
		e += k
		i = 0
	k *= 2
o1 = o
e1 = e
if i == 1:
	o -= s - l + 1
else:
	e -= s - l + 1
while s < r:
	s += k
	if i == 0:
		o1 += k
		i = 1
	else:
		e1 += k
		i = 0
	k *= 2
if i == 1:
	o1 -= s - r
else:
	e1 -= s - r
res = int(0)
res = (o1 - o) * (o1 + o)
res += int((e1 + 1) * e1 - (e + 1) * e)
res %= mod
print(res)


from math import *
import re

def f(n):
	p = 1
	st = 1
	ans = [0, 0]
	while p < n:
		ans[st] += p
		n -= p
		p *= 2
		st = 1 - st
	ans[st] += n
	(l, r) = (ans[0], ans[1])
	return l * (l + 1) + r * r
(q, w) = map(int, input().split())
print((f(w) - f(q - 1)) % (10 ** 9 + 7))


import math
from math import log, floor, ceil

def f(x):
	idx = 0
	co = 0
	ce = 0
	while True:
		if idx % 2 == 0:
			co += min(x - co - ce, 2 ** idx)
		else:
			ce += min(x - co - ce, 2 ** idx)
		if x - 2 ** idx <= 0:
			break
		idx += 1
	return ce * (ce + 1) + co ** 2
(l, r) = list(map(int, input().split()))
print((f(r) - f(l - 1)) % 1000000007)


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)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
import math
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def findit(l):
	if l == 0:
		return 0
	x = int(math.log2(l))
	if x % 2 == 1:
		f = x // 2 + 1
		summ1 = (4 ** f - 1) // 3
		summ1 = summ1 ** 2
		f = x // 2
		summ2 = 2 * ((4 ** f - 1) // 3)
		f = l - 2 ** x + 1
		summ2 = (f + summ2) * (f + 1 + summ2)
		return summ1 + summ2
	else:
		f = x // 2
		summ1 = (4 ** f - 1) // 3
		f = l - 2 ** x + 1
		summ1 = summ1 + f
		summ1 = summ1 ** 2
		f = x // 2
		summ2 = 2 * ((4 ** f - 1) // 3)
		summ2 *= summ2 + 1
		return summ1 + summ2

def main():
	tinn = 1
	for tin in range(tinn):
		(l, r) = map(int, input().split())
		print((findit(r) - findit(l - 1)) % 1000000007)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


MOD = 10 ** 9 + 7

def solve(x):
	(curr, now) = (1, 0)
	mt = [1, 2]
	t = 2
	z = 0
	sum = 0
	while x > 0:
		if curr > x:
			sum += (t * mt[z] + t * (x - 1)) * x // t
			sum % +MOD
			break
		sum += (t * mt[z] + t * (curr - 1)) * curr // t
		sum %= MOD
		mt[z] = mt[z] + curr * t
		z ^= 1
		x -= curr
		curr *= 2
	return sum
(l, r) = map(int, input().split())
print((solve(r) - solve(l - 1) + MOD) % MOD)


(l, r) = map(int, input().split())
m = bin(l - 1)
n = bin(r)
no1 = list(m)
no2 = list(n)
no1 = no1[2:]
no2 = no2[2:]
q = len(no2) - 1
ev = 0
odd = 0
flag = 1
for i in range(0, q):
	if i % 2 == 0:
		flag = 0
		odd += pow(2, i)
	else:
		flag = 1
		ev += pow(2, i)
s1 = pow(2, q) - 1
res1 = r - s1
if flag == 0:
	ev += res1
else:
	odd += res1
evensum = (ev + 1) * ev
oddsum = odd * odd
result1 = oddsum + evensum
q = len(no1) - 1
ev = 0
odd = 0
flag = 1
for i in range(0, q):
	if i % 2 == 0:
		flag = 0
		odd += pow(2, i)
	else:
		flag = 1
		ev += pow(2, i)
s1 = pow(2, q) - 1
res1 = l - 1 - s1
if flag == 0:
	ev += res1
else:
	odd += res1
evensum = (ev + 1) * ev
oddsum = odd * odd
result2 = oddsum + evensum
result = (result1 - result2) % 1000000007
print(result)


mod = 1000000007
S = [0] * 70
S[0] = 1
for i in range(1, 65):
	S[i] = S[i - 1] * 2
(l, r) = map(int, input().split())
lef = l
i = 1
j = 1
st = 0
f = True
while l > S[st]:
	l -= S[st]
	if f:
		f = False
		i += S[st]
	else:
		f = True
		j += S[st]
	st += 1
lenn = r - lef + 1
ans = 0
if f:
	f = False
	i += l - 1
	k = 2 * i - 1
	ll = lef - l + 1
	rr = ll + S[st] - 1
	if r <= rr:
		print((k * lenn % mod + lenn * (lenn - 1) % mod) % mod)
		exit(0)
	i -= l - 1
	lenn = rr - lef + 1
	ans += k * lenn % mod + lenn * (lenn - 1) % mod
	ans %= mod
	lef = rr + 1
	i += S[st]
	st += 1
else:
	f = True
	j += l - 1
	k = 2 * j
	ll = lef - l + 1
	rr = ll + S[st] - 1
	if r <= rr:
		print((k * lenn % mod + lenn * (lenn - 1) % mod) % mod)
		exit(0)
	j -= l - 1
	lenn = rr - lef + 1
	ans += k * lenn % mod + lenn * (lenn - 1) % mod
	ans %= mod
	lef = rr + 1
	j += S[st]
	st += 1
while lef <= r:
	if f:
		k = 2 * i - 1
		rr = lef + S[st] - 1
		if r <= rr:
			lenn = r - lef + 1
			print((ans + k * lenn % mod + lenn * (lenn - 1) % mod) % mod)
			exit(0)
		lenn = rr - lef + 1
		ans = (ans + k * lenn % mod + lenn * (lenn - 1) % mod) % mod
		lef = rr + 1
		i += S[st]
		st += 1
		f = False
	else:
		k = 2 * j
		rr = lef + S[st] - 1
		if r <= rr:
			lenn = r - lef + 1
			print((ans + k * lenn % mod + lenn * (lenn - 1) % mod) % mod)
			exit(0)
		lenn = rr - lef + 1
		ans = (ans + k * lenn % mod + lenn * (lenn - 1) % mod) % mod
		lef = rr + 1
		j += S[st]
		st += 1
		f = True


import math
MOD = 10 ** 9 + 7
(l, r) = map(int, input().split())
val = 1 << 60
i = 0
while 1:
	if r & val:
		val_r = 60 - i
		j = 0
		while 1:
			if l & val:
				val_l = val_r - j
				break
			val = val >> 1
			j += 1
		break
	val = val >> 1
	i += 1
arr_t = 6
arr_f = 1
arr = [1, 6]
arr_start = [1, 2]
for i in range(2, val_r + 1):
	if i % 2:
		arr_t = arr_t * 2 + 2
		arr_f = arr_f * 2
		arr.append(arr_t * arr_f)
		arr_start.append(arr_start[-1] * 2)
	else:
		arr_t = arr_t * 2
		arr_f = arr_f * 2
		arr.append(arr_t * arr_f)
		arr_start.append(arr_start[-1] * 2 - 1)
ret = sum(arr[val_l:val_r])
start = arr_start[val_l]
dif = l - (1 << val_l)
if not dif % 2:
	ret -= dif // 2 * (start + (start + 2 * (dif - 1)))
else:
	ret -= dif // 2 * (start + (start + 2 * (dif - 1)))
	ret -= start + 2 * (dif // 2)
start = arr_start[val_r]
dif = r - (1 << val_r)
if not dif % 2:
	ret += (dif + 1) // 2 * (start + (start + 2 * dif))
	ret += start + 2 * ((dif + 1) // 2)
else:
	ret += (dif + 1) // 2 * (start + (start + 2 * dif))
print(ret % MOD)


def f(n):
	i = 0
	x = n
	o = 0
	e = 0
	while x > 0:
		p = min(2 ** i, x)
		if i % 2 == 0:
			o = o + p
		else:
			e = e + p
		x = x - p
		i = i + 1
	return o * o + e * (e + 1)
m = 10 ** 9 + 7
(l, r) = map(int, input().split())
print((f(r) - f(l - 1)) % m)


(l, r) = map(int, input().split())
a = [i for i in range(61)]
l2 = r2 = 0
for i in range(61, -1, -1):
	if pow(2, i) <= l:
		l2 = i + 1
		break
for i in range(61, -1, -1):
	if pow(2, i) <= r:
		r2 = i + 1
		break
if l2 % 2 == 0:
	le = lo = 0
	for i in range(1, l2, 2):
		le += pow(2, i)
	le -= pow(2, l2) - l
	for i in range(0, l2 - 1, 2):
		lo += pow(2, i)
if l2 % 2 == 1:
	lo = le = 0
	for i in range(0, l2, 2):
		lo += pow(2, i)
	lo -= pow(2, l2) - l
	for i in range(1, l2 - 1, 2):
		le += pow(2, i)
if r2 % 2 == 0:
	re = ro = 0
	for i in range(1, r2, 2):
		re += pow(2, i)
	re -= pow(2, r2) - r - 1
	for i in range(0, r2 - 1, 2):
		ro += pow(2, i)
if r2 % 2 == 1:
	ro = re = 0
	for i in range(0, r2, 2):
		ro += pow(2, i)
	ro -= pow(2, r2) - r - 1
	for i in range(1, r2 - 1, 2):
		re += pow(2, i)
mod = pow(10, 9) + 7
so = ro % mod * (ro % mod) % mod - lo % mod * (lo % mod) % mod
se = re % mod * ((re + 1) % mod) % mod - le % mod * ((le + 1) % mod) % mod
print((so + se) % mod)


from math import *
(l, r) = map(int, input().split())

def compute(i):
	if i == 0:
		return 0
	even = floor(log2(i + 1)) // 2
	odd = ceil(floor(log2(i + 1)) / 2)
	if even == odd:
		middle_of_odd = True
	else:
		middle_of_odd = False
	even = 2 * (4 ** even - 1) // 3
	odd = (4 ** odd - 1) // 3
	if middle_of_odd:
		odd += i - 2 ** floor(log2(i + 1)) + 1
	else:
		even += i - 2 ** floor(log2(i + 1)) + 1
	return even * (even + 1) + odd ** 2
print((compute(r) - compute(l - 1)) % (10 ** 9 + 7))


MODN = 1000000007

def bitcount(num):
	bc = 0
	while num > 0:
		bc += 1
		num >>= 1
	return bc

def find_sum(idx):
	answer = 0
	r_bc = bitcount(idx)
	end = r_bc // 2
	(n_even, n_odd) = (0, 0)
	if r_bc % 2 == 0:
		for i in range(end):
			n_odd += 4 ** i
		n_even = idx - n_odd
	else:
		for i in range(end):
			n_even += 2 ** (i * 2 + 1)
		n_odd = idx - n_even
	max_odd = 1 + 2 * (n_odd - 1)
	max_even = 2 * n_even
	min_num = min(max_odd, max_even)
	max_num = max(max_odd, max_even)
	answer = min_num * (min_num + 1) // 2
	start = min_num + 1
	if start % 2 == 0:
		cnt = max_num // 2
		cnt2 = (start - 2) // 2
		answer += cnt * (cnt + 1) - cnt2 * (cnt2 + 1)
	else:
		cnt = (max_num + 1) // 2
		cnt2 = start // 2
		answer += cnt ** 2 - cnt2 ** 2
	return answer

def main():
	(l, r) = input().split()
	(l, r) = (int(l), int(r))
	answer = (find_sum(r) - find_sum(l - 1)) % MODN
	print(answer)
main()


import math

def eval(n):
	if n == 0:
		return 0
	pos = 0
	power = 0
	val = pow(2, 0)
	oddrank = val
	evenrank = 0
	while val < n:
		power += 1
		val1 = pow(2, power)
		if power % 2 == 1:
			evenrank += val1
		else:
			oddrank += val1
		val += val1
	evenpos = 0
	oddpos = 0
	if power % 2 == 1:
		evenpos = evenrank - pow(2, power) + n - (val - pow(2, power))
		oddpos = oddrank
	else:
		oddpos = oddrank - pow(2, power) + n - (val - pow(2, power))
		evenpos = evenrank
	MOD = 1000000007
	evensum = evenpos * (evenpos + 1)
	evensum = evensum
	oddsum = oddpos * oddpos
	oddsum = oddsum
	sum1 = evensum + oddsum
	sum1 = sum1
	return sum1
t = list(map(int, input().split()))
l = t[0]
r = t[1]
print((eval(r) - eval(l - 1)) % 1000000007)


import math
(l, r) = map(int, input().split())
(x, c, c1, c2, set) = (0, 0, 0, 0, 0)
while x < l:
	x = x + 2 ** c
	if set == 0:
		set = 1
		c1 += 2 ** c
	elif set == 1:
		set = 0
		c2 += 2 ** c
	c += 1
if set == 0:
	c2 -= x - l
	c2 -= 1
else:
	c1 -= x - l
	c1 -= 1
(y, rc, rc1, rc2, rset) = (0, 0, 0, 0, 0)
while y < r:
	y = y + 2 ** rc
	if rset == 0:
		rset = 1
		rc1 += 2 ** rc
	elif rset == 1:
		rset = 0
		rc2 += 2 ** rc
	rc += 1
if rset == 0:
	rc2 -= y - r
else:
	rc1 -= y - r
ans1 = c1 % 1000000007 * (c1 % 1000000007) % 1000000007
ans1 = ans1 % 1000000007
ans1 += c2 % 1000000007 * ((c2 + 1) % 1000000007) % 1000000007
ans1 = ans1 % 1000000007
ans2 = rc1 % 1000000007 * (rc1 % 1000000007) % 1000000007
ans2 = ans2 % 1000000007
ans2 += rc2 % 1000000007 * ((rc2 + 1) % 1000000007) % 1000000007
ans2 = ans2 % 1000000007
print(int(ans2 - ans1 + 1000000007) % 1000000007)


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

def getSum(s, e, a, ind):
	i = 0
	val = 2
	while val - 1 < ind:
		i += 1
		val *= 2
	remain = ind - val // 2 + 1
	ans = remain * (2 * s[i] + (remain - 1) * 2) // 2
	if i != 0:
		ans += a[i - 1]
	return ans

def solve(l, r):
	if l - 1 == 0:
		return getSum(s, e, a, r) % 1000000007
	return (getSum(s, e, a, r) - getSum(s, e, a, l - 1)) % 1000000007
s = [0 for i in range(65)]
e = [0 for i in range(65)]
a = [0 for i in range(65)]
s[0] = 1
e[0] = 1
s[1] = 2
e[1] = 4
a[0] = 1
a[1] = 7
for i in range(2, len(s)):
	num = 2 ** i
	s[i] = e[i - 2] + 2
	e[i] = s[i] + 2 ** (i + 1) - 2
	a[i] = a[i - 1] + num * (2 * s[i] + (num - 1) * 2) // 2
print(solve(l, r))


MOD = 10 ** 9 + 7

def get_for_pref(border):
	even = 1
	odd = 2
	ans = 0
	total = 0
	hod = 0
	turn = 1
	while total < border:
		if border - total < turn:
			turn = border - total
		(begin, end) = (0, 0)
		if hod & 1:
			begin = odd
		else:
			begin = even
		end = begin + turn * 2 - 2
		if hod & 1:
			odd = end + 2
		else:
			even = end + 2
		ans += (begin + end) * turn // 2
		hod += 1
		total += turn
		turn *= 2
	return ans
(l, r) = list(map(int, input().split()))
print((get_for_pref(r) - get_for_pref(l - 1)) % MOD)


import math

def get_sum(msum, MOD):
	n = msum // 2 + msum % 2 + 1
	n = int(math.ceil(math.log(n, 2)))
	rem = msum - 2 ** n + 1
	odd_pow = n // 2 + n % 2
	even_pow = n - odd_pow
	odd_terms = (4 ** odd_pow - 1) // 3
	even_terms = 2 * 4 ** even_pow // 3
	if n % 2 == 0:
		odd_terms += rem
	else:
		even_terms += rem
	ans1 = even_terms * (1 + even_terms) % MOD
	ans2 = odd_terms * odd_terms % MOD
	return (ans1 + ans2) % MOD
(l, r) = map(int, input().split())
MOD = int(1000000000.0 + 7)
left = get_sum(l - 1, MOD)
right = get_sum(r, MOD)
right -= left
right %= MOD
if right < 0:
	right += MOD
print(right)


mod = 1000000007

def firstodds(n):
	return n * n % mod

def firstevens(n):
	return n * (n + 1) % mod

def thresholds(k):
	if k % 2 == 0:
		a = (2 ** k - 1) // 3
		b = (2 ** (k + 1) - 2) // 3
	else:
		a = (2 ** (k + 1) - 1) // 3
		b = (2 ** k - 2) // 3
	return [a, b]

def score(n):
	if n == 0:
		return 0
	k = 0
	while 2 ** k <= n:
		k += 1
	t = thresholds(k)
	(a, b) = (t[0], t[1])
	numbertoremove = 2 ** k - 1 - n
	if k % 2 == 1:
		a -= numbertoremove
	else:
		b -= numbertoremove
	return firstodds(a) + firstevens(b)
(l, r) = [int(x) for x in input().split()]
print((score(r) - score(l - 1)) % mod)


(l, r) = 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
	(odd, eve, temp) = (0, 0, 0)
	for i in range(c):
		if i % 2 == 0:
			odd += pow(2, i)
		else:
			eve += pow(2, i)
	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)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *
mod = 10 ** 9 + 7

def sumTo(n):
	global mod
	k = 1
	s = [0, 0]
	m = 0
	while sum(s) < n:
		m = 1 - m
		if sum(s) + k > n:
			k = n - sum(s)
		s[m] = s[m] + k
		if sum(s) == n:
			break
		k = k * 2
	return s[0] * (s[0] + 1) + s[1] ** 2 % mod

def main():
	global mod
	(l, r) = [int(x) for x in stdin.readline().split()]
	stdout.write(str((sumTo(r) - sumTo(l - 1) + mod) % mod))
	return 0
main()


import bisect, math
(left, right) = map(int, input().strip().split())
if left == 1 and right == 1:
	print(1)
else:
	to_mod = 1000000007
	ans = 0
	range_list = [1, 2]
	left_num = [1, 2]
	temp = 4
	while temp < right:
		range_list.append(temp)
		left_num.append(left_num[-2] + temp // 2)
		temp *= 2
	range_list.append(temp)
	left_num.append(left_num[-2] + temp // 2)

	def next_range(left):
		nx = bisect.bisect_right(range_list, left)
		return range_list[nx]

	def in_same_range(left, right):
		return bisect.bisect(range_list, left) == bisect.bisect(range_list, right)

	def index_to_num(left):
		index = bisect.bisect(range_list, left) - 1
		return left_num[index] + 2 * (left - range_list[index])

	def cal_sum(left_num, right_num):
		(right_seq, left_seq) = (right_num // 2 + (1 if right_num % 2 != 0 else 0), left_num // 2 - (1 if right_num % 2 == 0 else 0))
		result = right_seq ** 2 - left_seq ** 2
		if left_num % 2 == 0:
			result = result - left_seq + right_seq
		return result

	def cal_left_to_right(left):
		add_index = bisect.bisect(range_list, left) - 1
		add = range_list[add_index]
		return left_num[add_index] + 2 * (add - 1)
	while left <= right:
		if in_same_range(left, right):
			left_number = index_to_num(left)
			right_number = index_to_num(right)
			ans += cal_sum(left_number, right_number) % to_mod
			break
		else:
			left_number = index_to_num(left)
			right_number = cal_left_to_right(left)
			ans += cal_sum(left_number, right_number) % to_mod
			left = next_range(left)
	print(ans % to_mod)


powsum = [0] * 80

def find(n):
	(l, r) = (0, 79)
	while l < r:
		mid = (l + r + 1) // 2
		if powsum[mid] > n:
			r = mid - 1
		else:
			l = mid
	return l

def calc(n):
	posn = find(n)
	if posn % 2 == 0:
		pos = posn // 2
		q = 4
		first1 = 2
		last1 = 2 * 2 * (1 - q ** pos) // (1 - q)
		num1 = 2 * (1 - q ** pos) // (1 - q)
		sum1 = (first1 + last1) * num1 // 2
		first2 = 1
		last2 = ((1 - q ** pos) // (1 - q) - 1) * 2 + 1
		num2 = (1 - q ** pos) // (1 - q)
		sum2 = (first2 + last2) * num2 // 2
		first3 = 2 * ((1 - q ** pos) // (1 - q)) + 1
		last3 = first3 + (n - powsum[posn] - 1) * 2
		num3 = n - powsum[posn]
		sum3 = (first3 + last3) * num3 // 2
	else:
		pos1 = posn // 2
		pos2 = (posn + 1) // 2
		q = 4
		first1 = 2
		last1 = 2 * 2 * (1 - q ** pos1) // (1 - q)
		num1 = 2 * (1 - q ** pos1) // (1 - q)
		sum1 = (first1 + last1) * num1 // 2
		first2 = 1
		last2 = 1 + ((1 - q ** pos2) // (1 - q) - 1) * 2
		num2 = (1 - q ** pos2) // (1 - q)
		sum2 = (first2 + last2) * num2 // 2
		first3 = 4 * ((1 - q ** pos1) // (1 - q)) + 2
		last3 = first3 + (n - powsum[posn] - 1) * 2
		num3 = n - powsum[posn]
		sum3 = (first3 + last3) * num3 // 2
	return sum1 + sum2 + sum3
(l, r) = map(int, input().split())
for i in range(1, 80):
	powsum[i] = powsum[i - 1] + 2 ** (i - 1)
print((calc(r) - calc(l - 1)) % int(1000000000.0 + 7))


from math import log2
(A, B) = map(int, input().split())
MOD = int(1000000000.0 + 7)

def gs(x):
	if x == 0:
		return 0
	k = int(log2(x))
	sm = 0
	if k % 2 == 0:
		c = (4 ** (k // 2) - 1) // 3 + x - ((1 << k) - 1)
		d = 2 * (4 ** (k // 2) - 1) // 3
		sm += c * c + d * (d + 1)
		sm %= MOD
	else:
		c = (4 ** ((k + 1) // 2) - 1) // 3
		d = 2 * (4 ** (k // 2) - 1) // 3 + x - ((1 << k) - 1)
		sm += c * c + d * (d + 1)
		sm %= MOD
	return sm
ans = gs(B) + MOD - gs(A - 1)
print(ans % MOD)


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
mod = 10 ** 9 + 7
(r, l) = mi()
first = r - 1
second = l
po = 0
numodds = 0
numevens = 0
while 2 ** (po + 1) - 1 <= first:
	if po % 2 == 0:
		numodds += 2 ** po
	if po % 2 == 1:
		numevens += 2 ** po
	po += 1
if po % 2 == 0:
	numodds += first - (2 ** po - 1)
if po % 2 == 1:
	numevens += first - (2 ** po - 1)
sum1 = (2 * numodds * numodds // 2 + (2 * numevens + 2) * numevens // 2) % mod
numodds = 0
numevens = 0
po = 0
while 2 ** (po + 1) - 1 <= second:
	if po % 2 == 0:
		numodds += 2 ** po
	if po % 2 == 1:
		numevens += 2 ** po
	po += 1
if po % 2 == 0:
	numodds += second - (2 ** po - 1)
if po % 2 == 1:
	numevens += second - (2 ** po - 1)
sum2 = (2 * numodds * numodds // 2 + (2 * numevens + 2) * numevens // 2) % mod
print((sum2 - sum1) % mod)


import sys
zz = 1
sys.setrecursionlimit(10 ** 5)
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def ii():
	return input().rstrip()

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def gtc(tc, ans):
	print('Case #' + str(tc) + ':', ans)

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j, n, m):
	return 0 <= i < n and 0 <= j < m

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
uu = t

def sumap(a, n, d=2):
	return max(0, n * (2 * a + (n - 1) * d) // 2)

def lastap(a, n, d=2):
	return a + (n - 1) * d
while t > 0:
	t -= 1
	(l, r) = mi()
	c = p = 0
	mod = 10 ** 9 + 7
	a = []
	o = 1
	e = 2
	while c <= 10 ** 20:
		if p % 2 == 0:
			w = sumap(o, 2 ** p, 2) % mod
			pp = o
			o = lastap(o, 2 ** p + 1, 2)
		else:
			w = sumap(e, 2 ** p, 2) % mod
			pp = e
			e = lastap(e, 2 ** p + 1, 2)
		c += 2 ** p
		p += 1
		a.append([w, pp, p - 1])
	c = p = ans = i = 0
	end = -1
	while c < r:
		if c + 2 ** p > r:
			end = i
			break
		if c + 2 ** p >= l:
			ans += a[i][0] - sumap(a[i][1], max(0, l - c - 1))
			ans %= mod
		elif c > l:
			ans = (ans + a[i][0]) % mod
		c += 2 ** p
		p += 1
		i += 1
	if end != -1:
		ans = (ans + sumap(a[end][1], r - c)) % mod
		if a[end][1] < l:
			ans = (ans - sumap(a[end][1], l - c - 1) + mod) % mod
	print(ans)


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
(l, r) = f(1)

def func(l):
	if l == 0:
		return 0
	n = int(math.log(l + 1, 2))
	if n % 2 == 0:
		n1 = n // 2
		n2 = n // 2
	else:
		n1 = n // 2 + 1
		n2 = n // 2

	def geom_sum(base, n, coef):
		return coef * (base ** n - 1) // (base - 1)

	def ariph_sum(diff, start, n):
		return (2 * start + (n - 1) * diff) * n // 2
	ost = l - geom_sum(2, n, 1)
	if n1 == n2:
		count1 = geom_sum(4, n1, 1) + ost
		count2 = geom_sum(4, n2, 2)
	else:
		count1 = geom_sum(4, n1, 1)
		count2 = geom_sum(4, n2, 2) + ost
	return ariph_sum(2, 1, count1) + ariph_sum(2, 2, count2)
print((func(r) - func(l - 1)) % (10 ** 9 + 7))


import sys
import math
mod = 10 ** 9 + 7

def get(num):
	(cur, odd, even) = (0, 0, 0)
	while num > 0:
		if cur % 2 == 0:
			if num >= 1 << cur:
				odd += 1 << cur
				num -= 1 << cur
			else:
				odd += num
				num = 0
		elif num >= 1 << cur:
			even += 1 << cur
			num -= 1 << cur
		else:
			even += num
			num = 0
		cur += 1
	return (odd, even)
(l, r) = map(int, sys.stdin.readline().split())
ans = 0
(odd, even) = get(r)
ans += pow(odd, 2, mod)
ans += even % mod * (even % mod + 1) % mod
(odd, even) = get(l - 1)
ans -= pow(odd, 2, mod)
ans -= even % mod * (even % mod + 1) % mod
print(ans % mod)


mod = int(1000000000.0 + 7)

def seq_sum(x):
	(even, odd, power) = [0, 0, 0]
	while x - 2 ** power >= 0:
		if power % 2 == 0:
			odd = odd + 2 ** power
		else:
			even = even + 2 ** power
		x = x - 2 ** power
		power = power + 1
	if power % 2 == 0:
		odd = odd + x
	else:
		even = even + x
	return odd * odd + even * (even + 1)
(l, r) = [int(i) for i in input().split()]
ans = seq_sum(r) - seq_sum(l - 1)
print(ans % mod)


MOD = 1000000007
(l, r) = list(map(int, input().split()))
two = 1
cnt1 = 0
cnt2 = 0
total = 0
sum1 = 0
sum2 = 0
lr = 0
oddoreven = 0
l -= 1
while lr < 2:
	if oddoreven == 0:
		cnt1 += two
	else:
		cnt2 += two
	total += two
	if lr == 0:
		if total == l:
			sum1 = sum1 + (1 + (cnt1 * 2 - 1)) * cnt1 // 2
			sum1 = sum1 + (2 + cnt2 * 2) * cnt2 // 2
			lr = 1
		elif total > l:
			x = l - (total - two)
			if oddoreven == 1:
				sum1 = sum1 + (1 + cnt1 * 2 - 1) * cnt1 // 2
				sum1 = sum1 + (2 + (cnt2 - two + x) * 2) * (cnt2 - two + x) // 2
			else:
				sum1 = sum1 + (1 + (cnt1 - two + x) * 2 - 1) * (cnt1 - two + x) // 2
				sum1 = sum1 + (2 + cnt2 * 2) * cnt2 // 2
			lr = 1
	if lr == 1:
		if total == r:
			sum2 = sum2 + (1 + (cnt1 * 2 - 1)) * cnt1 // 2
			sum2 = sum2 + (2 + cnt2 * 2) * cnt2 // 2
			lr = 2
		elif total > r:
			x = r - (total - two)
			if oddoreven == 1:
				sum2 = sum2 + (1 + cnt1 * 2 - 1) * cnt1 // 2
				sum2 = sum2 + (2 + (cnt2 - two + x) * 2) * (cnt2 - two + x) // 2
			else:
				sum2 = sum2 + (1 + (cnt1 - two + x) * 2 - 1) * (cnt1 - two + x) // 2
				sum2 = sum2 + (2 + cnt2 * 2) * cnt2 // 2
			lr = 2
	two <<= 1
	oddoreven ^= 1
ans = sum2 - sum1
print(ans % MOD)


(l, r) = map(int, input().split())
mod = 1000000007
o = e = 0
x = i = 1
while x < l:
	if i % 2:
		e += x // 2
	else:
		o += x // 2
	if x << 1 < l:
		x = x << 1
	else:
		if i % 2:
			o += l - x
		else:
			e += l - x
		break
	i += 1
s1 = (e * (e + 1) + o * o) % mod
o = e = 0
x = i = 1
while x <= r:
	if i % 2:
		e += x // 2
	else:
		o += x // 2
	if x << 1 <= r:
		x = x << 1
	else:
		if i % 2:
			o += r - x + 1
		else:
			e += r - x + 1
		break
	i += 1
s2 = (e * (e + 1) + o * o) % mod
print((s2 - s1 % mod + mod) % mod)


from sys import stdin

def function(n):
	global const
	const = 10 ** 9 + 7
	(a, b, t, s) = (0, 0, 0, 0)
	i = 1
	while i:
		t += i
		if t > n:
			t -= i
			break
		if s == 0:
			a += i
		else:
			b += i
		i *= 2
		s = 1 - s
	if s == 0:
		a += n - t
	else:
		b += n - t
	ans = (b % const * ((b + 1) % const) + a % const * ((a + 1) % const) - a + const) % const
	return ans
(l, r) = [int(i) for i in stdin.readline().split()]
print((function(r) - function(l - 1) + const) % const)


def solve(n):
	z = 0
	odd = 0
	even = 0
	for i in range(100):
		if z + 2 ** i >= n:
			break
		if i % 2 == 0:
			odd += 2 ** i
		else:
			even += 2 ** i
		z += 2 ** i
	if i % 2 == 0:
		odd += n - z
	else:
		even += n - z
	z1 = even * (4 + (even - 1) * 2) // 2
	z2 = odd * (2 + (odd - 1) * 2) // 2
	return z1 + z2
(l, r) = map(int, input().split())
mod = 10 ** 9 + 7
print(abs(solve(l - 1) - solve(r)) % mod)


MOD = int(1000000000.0 + 7)

def f(ind):
	res = int(0)
	last0 = int(2)
	last1 = int(1)
	cur = int(0)
	power = int(1)
	pow_num = int(1)
	while cur + power <= ind:
		if pow_num:
			res = ((last1 + last1 + (power - 1) * 2) * power // 2 % MOD + res) % MOD
			last1 += power * 2
		else:
			res = ((last0 + last0 + (power - 1) * 2) * power // 2 % MOD + res) % MOD
			last0 += power * 2
		cur += power
		pow_num ^= 1
		power <<= 1
	if cur + power > ind:
		cnt = ind - cur
		if pow_num:
			res = ((last1 + last1 + (cnt - 1) * 2) * cnt // 2 % MOD + res) % MOD
		else:
			res = ((last0 + last0 + (cnt - 1) * 2) * cnt // 2 % MOD + res) % MOD
	return int(res)
(l, r) = map(int, input().split())
print((f(r) - f(l - 1) + MOD) % MOD)


MOD = int(1000000000.0 + 7)

def get_e(x):
	return x * (x + 1) % MOD

def get_o(x):
	return x * x % MOD

def get(r):
	turn_odd = True
	j = 0
	(cnte, cnto) = (0, 0)
	while True:
		if r <= 0:
			break
		k = min(r, 1 << j)
		r -= k
		if turn_odd:
			cnto += k
		else:
			cnte += k
		turn_odd ^= 1
		j += 1
	ans = get_e(cnte) + get_o(cnto)
	return ans % MOD
(L, R) = map(int, input().split())
print((get(R) - get(L - 1) + MOD) % MOD)


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

def f(x):
	c = 1
	st = 1
	(o, e) = (0, 0)
	while x > st:
		x -= st
		if c:
			o += st
		else:
			e += st
		st *= 2
		c = 1 - c
	if c:
		o += x
	else:
		e += x
	return o ** 2 + e * (e + 1)
print((f(r) - f(l - 1)) % (10 ** 9 + 7))


(l, r) = map(int, input().split())
(l, r) = (l - 1, r - 1)
past_odd = past_even = 0
odd = True
jump = 1
i = 0
while i + jump <= l:
	i += jump
	if odd:
		past_odd += jump
	else:
		past_even += jump
	jump += jump
	odd = not odd
if odd:
	first_odd = past_odd + (l - i)
	first_even = past_even
else:
	first_odd = past_odd
	first_even = past_even + (l - i)
while i + jump <= r:
	i += jump
	if odd:
		past_odd += jump
	else:
		past_even += jump
	jump += jump
	odd = not odd
if odd:
	last_odd = past_odd + (r - i) + 1
	last_even = past_even
else:
	last_odd = past_odd
	last_even = past_even + (r - i) + 1
print(((last_odd * 2 - 1 + (first_odd * 2 + 1)) // 2 * (last_odd - first_odd) + (last_even * 2 + (first_even + 1) * 2) // 2 * (last_even - first_even)) % 1000000007)


import heapq
import queue
from collections import *
import math

def sieve(n):
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return primes

def getelem(x, sm):
	ret = 0
	if sm % 2 == 0:
		temp = (sm - 2) // 2 + 1
		temp2 = (int(pow(4, temp)) - 1) // 3
		y = temp2 + x - int(pow(2, sm))
		ret = 3 + (y - 1) * 2
	else:
		temp = (sm - 3) // 2 + 1
		temp2 = 2 * ((int(pow(4, temp)) - 1) // 3)
		y = temp2 + x - int(pow(2, sm))
		ret = 4 + (y - 1) * 2
	return ret
m = 1000000007
(l, r) = [int(ele) for ele in input().split()]
lsm = int(math.log(l, 2))
rsm = int(math.log(r, 2))
ret = 0
while lsm <= rsm:
	if lsm == rsm:
		rr = getelem(r, rsm)
		ll = getelem(l, lsm)
		temp = (rr - ll) // 2 + 1
		ret = (ret + (temp * ll % m + temp * (temp - 1) % m) % m) % m
		break
	else:
		ll = getelem(l, lsm)
		rr = getelem(int(pow(2, lsm + 1)) - 1, lsm)
		temp = (rr - ll) // 2 + 1
		ret = (ret + (temp * ll % m + temp * (temp - 1) % m) % m) % m
		l = int(pow(2, lsm + 1))
		lsm += 1
print(ret)


(l, r) = map(int, input().split())
ans = 0
M = 10 ** 9 + 7

def func(n):
	a = 0
	odd = 1
	even = 2
	s = 0
	ret = 0
	while True:
		p = 2 ** a
		flag = False
		if s + p >= n:
			t = n - s
			flag = True
		else:
			t = p
		t = int(t % M)
		if a % 2 == 0:
			ret = (ret + (odd + odd + (t - 1) * 2) // 2 * t) % M
			odd += p * 2
		else:
			ret = (ret + (even + even + (t - 1) * 2) // 2 * t) % M
			even += p * 2
		if flag:
			break
		a += 1
		s += p
	return ret
ans = (func(r) - func(l - 1) + M) % M
ans = int(ans)
print(ans)


import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
mod = 10 ** 9 + 7
yon = [4 ** i for i in range(10000)]
rui = [0] * (len(yon) + 1)
for i in range(len(yon)):
	rui[i + 1] = rui[i] + yon[i]

def sum_ans(x):
	if x == 0:
		return 0
	a = x.bit_length()
	ans = 0
	for i in range(a - 1):
		if i % 2 == 0:
			ki = i // 2
			hazi = rui[ki]
			hazi = hazi * 2 + 1
			ko = 4 ** ki
			ans += (hazi + hazi + (ko - 1) * 2) * ko // 2
			ans %= mod
		else:
			ki = i // 2
			hazi = rui[ki] * 2
			hazi = hazi * 2 + 2
			ko = 4 ** ki * 2
			ans += (hazi + hazi + (ko - 1) * 2) * ko // 2
			ans %= mod
	x -= 2 ** (a - 1) - 1
	if a % 2 == 1:
		ki = a // 2
		hazi = rui[ki]
		hazi = hazi * 2 + 1
		ans += (hazi + hazi + (x - 1) * 2) * x // 2
		ans %= mod
	else:
		ki = (a - 1) // 2
		hazi = rui[ki] * 2
		hazi = hazi * 2 + 2
		ans += (hazi + hazi + (x - 1) * 2) * x // 2
		ans %= mod
	return ans
(n, m) = map(int, input().split())
print((sum_ans(m) + mod - sum_ans(n - 1)) % 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) = map(int, input().split())
print((p + sum_special(r) - sum_special(l - 1)) % p)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
mod = int(1000000000.0) + 7

def power(k, n):
	if n == 0:
		return 1
	if n % 2:
		return power(k, n - 1) * k % mod
	t = power(k, n // 2)
	return t * t % mod

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def main():
	(l, r) = map(int, input().split())
	k = 1
	e = 0
	o = 0
	f = 0
	while r:
		t = min(r, k)
		if f == 0:
			o += t
		else:
			e += t
		f ^= 1
		r -= t
		k *= 2
	ans = e % mod * ((e + 1) % mod) % mod + (o % mod) ** 2 % mod
	l -= 1
	k = 1
	e = 0
	o = 0
	f = 0
	while l:
		t = min(l, k)
		if f == 0:
			o += t
		else:
			e += t
		f ^= 1
		l -= t
		k *= 2
	ans1 = (o % mod) ** 2 % mod + e % mod * ((e + 1) % mod) % mod
	print((ans - ans1 + mod) % mod)
	return
main()


def f(l, cut, right):
	if not right:
		no = 2 ** cut - l
		if cut % 2:
			end = (2 ** (cut + 1) - 1) // 3 * 2 - 1
		else:
			end = (2 ** (cut + 1) - 2) // 3 * 2
		return no * (end - no + 1)
	else:
		no = l - 2 ** cut + 1
		if cut % 2:
			start = (2 ** cut - 2) // 3 * 2 + 2
		else:
			start = (2 ** cut - 1) // 3 * 2 + 1
		return no * (start + no - 1)
import math
(l, r) = map(int, input().split())
l_cut = math.ceil(math.log2(l + 1))
r_cut = math.floor(math.log2(r + 1))
m = 10 ** 9 + 7
over_2 = pow(2, m - 2, m) % m
over_3 = pow(3, m - 2, m) % m
cum = []
for i in range(64):
	if i % 2 == 0:
		cum.append(pow(2, i, m) * (pow(2, i + 2, m) + pow(2, i, m) - 2) * over_3 % m)
	else:
		cum.append(pow(2, i, m) * (pow(2, i + 2, m) + pow(2, i, m) - 1) * over_3 % m)
ans = 0
for i in range(l_cut, r_cut):
	ans += cum[i]
ans %= m
ans += f(l, l_cut, False)
ans += f(r, r_cut, True)
if l_cut > r_cut:
	ans -= cum[l_cut - 1]
print(ans % m)


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

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
	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
	return ans
print(((sum(r) - sum(l - 1)) % MOD + MOD) % MOD)


from collections import defaultdict
MOD = 1000000007
inv2 = 500000004

def arithProg(beg, cnt):
	a = beg
	b = beg + (cnt - 1) * 2
	ans = cnt * (a + b) * inv2
	return ans % MOD

def solve(u):
	if u == 0:
		return 0
	fac = 1
	f1 = 1
	f2 = 2
	taken = 0
	turn = 0
	res = 0
	while taken + fac <= u:
		taken += fac
		if turn == 0:
			res += arithProg(f1, fac)
			f1 += 2 * fac
		else:
			res += arithProg(f2, fac)
			f2 += 2 * fac
		res %= MOD
		fac = fac * 2
		turn = (turn + 1) % 2
	if taken < u:
		rem = u - taken
		if turn == 0:
			res += arithProg(f1, rem)
		else:
			res += arithProg(f2, rem)
		res %= MOD
	return res
(l, r) = [int(x) for x in input().split(' ')]
print(int((solve(r) - solve(l - 1) + MOD) % MOD))


INV = 500000004
MOD = 1000000007

def get(x):
	global INV, MOD
	if x == 0:
		return 0
	res = 0
	cnt = 1
	f1 = 1
	f2 = 2
	i = 1
	while x >= cnt:
		x -= cnt
		if i % 2 == 1:
			res += (2 * f1 + 2 * (cnt - 1)) * cnt // 2
			f1 += 2 * cnt
		else:
			res += (2 * f2 + 2 * (cnt - 1)) * cnt // 2
			f2 += 2 * cnt
		cnt *= 2
		i += 1
	if x > 0:
		if i % 2 == 1:
			res += (2 * f1 + 2 * (x - 1)) * x // 2
			f1 += 2 * cnt
		else:
			res += (2 * f2 + 2 * (x - 1)) * x // 2
			f2 += 2 * cnt
	return res
(L, R) = map(int, input().split())
print((get(R) - get(L - 1)) % MOD)


MOD = 1000000007

def solve(r):
	n = r.bit_length()
	while 2 ** n < r:
		n += 1
	while 2 ** n > r:
		n -= 1
	odds_number = (4 ** ((n + 1) // 2) - 1) // 3
	if not n % 2:
		odds_number += r + 1 - 2 ** n
	evens_number = r - odds_number
	return evens_number * (evens_number + 1) + odds_number ** 2

def main():
	(l_, r) = map(int, input().split())
	l_ -= 1
	res = solve(r)
	if l_:
		res = MOD + res - solve(l_) % MOD
	print(res % MOD)
main()


import math
MODULO = 1000000007

def count_odd_numbers(n: int) -> int:
	if n < 0:
		return 0
	odd_numbers = 0
	for i in range(0, n + 1):
		odd_numbers += 2 * 4 ** i
	return odd_numbers

def count_even_numbers(n: int) -> int:
	if n < 0:
		return 0
	even_numbers = 0
	for i in range(0, n + 1):
		even_numbers += 4 ** i
	return even_numbers

def get_even_number_and_odd_number(n: int) -> (int, int):
	odd_numbers = 0
	even_numbers = 0
	i = 0
	pow_value = 1
	while True:
		if n >= pow_value and n < pow_value * 2:
			odd_numbers = count_odd_numbers(i - 1)
			even_numbers = n - odd_numbers
			break
		if n >= pow_value * 2 and n < pow_value * 4:
			even_numbers = count_even_numbers(i)
			odd_numbers = n - even_numbers
			break
		i += 1
		pow_value *= 4
	return (even_numbers, odd_numbers)

def calculate_by_n(n: int) -> int:
	if n < 2:
		return n
	(even_numbers, odd_numbers) = get_even_number_and_odd_number(n)
	sum_of_even = (even_numbers % MODULO) ** 2 % MODULO
	sum_of_odd = odd_numbers % MODULO * ((odd_numbers + 1) % MODULO) % MODULO
	return (sum_of_even + sum_of_odd) % MODULO
n_and_m = input().split(' ')
n = int(n_and_m[0])
m = int(n_and_m[1])
result = (calculate_by_n(m) - calculate_by_n(n - 1)) % MODULO
print(result)


(a, b) = map(int, input().split())
finish = 0
ans = 0
mod = 1000000007

def run(tartet):
	stop = 0
	time = 1
	total = 0
	switch = 0
	count = [0, 0]
	ans = 0
	while not stop and total != tartet:
		if total + time >= tartet:
			next = tartet - total
			n = next
			stop = 1
		else:
			n = time
			next = time
		if not switch:
			num = (count[0] + next) * 2 - 1
			num2 = (count[0] + 1) * 2 - 1
		else:
			num = (count[1] + next) * 2
			num2 = (count[1] + 1) * 2
		ans += n * (num + num2) // 2
		total += next
		if not switch:
			count[0] += next
		else:
			count[1] += next
		switch ^= 1
		time *= 2
	return ans
r = run(b)
l = run(a - 1)
print((r - l) % mod)


(l, r) = map(int, input().split())
n = 0
cf = 0
while cf < l:
	n = n + 1
	cf = 2 ** n - 1
if n % 2 != 0:
	i = n - 1
	j = n - 2
else:
	i = n - 2
	j = n - 1
ef = 0
while i > 0:
	ef = ef + 2 ** (i - 1)
	i = i - 2
of = 0
while j > 0:
	of = of + 2 ** (j - 1)
	j = j - 2
y = l - 2 ** (n - 1)
if n % 2 == 0:
	ef = ef + y
else:
	of = of + y
sum1 = of ** 2
sum2 = ef * (ef + 1)
sumA = sum1 + sum2
n = 0
cf = 0
while cf < r:
	n = n + 1
	cf = 2 ** n - 1
if n % 2 != 0:
	i = n - 1
	j = n - 2
else:
	i = n - 2
	j = n - 1
ef = 0
while i > 0:
	ef = ef + 2 ** (i - 1)
	i = i - 2
of = 0
while j > 0:
	of = of + 2 ** (j - 1)
	j = j - 2
y = r - 2 ** (n - 1) + 1
if n % 2 == 0:
	ef = ef + y
else:
	of = of + y
sum1 = of ** 2
sum2 = ef * (ef + 1)
sumB = sum1 + sum2
ans = sumB - sumA
ans = ans % 1000000007
print(ans)


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		l = self.next_int()
		r = self.next_int()
		print((self.f(r) - self.f(l - 1)) % 1000000007)

	def f(self, k):
		s = [0, 0]
		for i in range(0, 70):
			if k <= 0:
				break
			d = 1 << i
			if k >= d:
				s[i % 2] += d
			else:
				s[i % 2] += k
			k -= d
		return s[0] ** 2 + s[1] * (s[1] + 1)
Main().solve()


from bisect import bisect_right, bisect_left
m = 10 ** 9 + 7

def actual_value(x, priority):
	if priority % 2 == 0:
		return x * (x + 1)
	else:
		return x * x
(l, r) = map(int, input().split())
sum_arr = [0]
for i in range(1, 63):
	sum_arr.append(pow(2, i) - 1)
odd = [0]
even = [0]
for i in range(0, 63):
	if i % 2 == 0:
		odd.append(pow(2, i) + odd[-1])
		even.append(even[-1])
	else:
		even.append(pow(2, i) + even[-1])
		odd.append(odd[-1])
left = bisect_left(sum_arr, l)
right = bisect_left(sum_arr, r)
left -= 1
right -= 1
(left_odd, left_even, right_odd, right_even) = (0, 0, 0, 0)
if left % 2 == 0:
	left_odd = odd[left] + l - sum_arr[left] - 1
	left_even = even[left]
else:
	left_odd = odd[left]
	left_even = even[left] + l - sum_arr[left] - 1
if right % 2 == 0:
	right_odd = odd[right] + r - sum_arr[right]
	right_even = even[right]
else:
	right_odd = odd[right]
	right_even = even[right] + r - sum_arr[right]
act_even = actual_value(right_even, 0) - actual_value(left_even, 0)
act_odd = actual_value(right_odd, 1) - actual_value(left_odd, 1)
print((act_even + act_odd) % m)


MOD = 1000000007

def find_sum(num):
	deg = 0
	odd = 0
	even = 0
	x = num
	while x > 0:
		if deg % 2 == 0:
			odd += min(1 << deg, x)
		else:
			even += min(1 << deg, x)
		x -= 1 << deg
		deg += 1
	return odd * odd + even * (even + 1)
(l, r) = (int(x) for x in input().split())
print((MOD + find_sum(r) % MOD - find_sum(l - 1) % MOD) % MOD)


def sumPA(i, f):
	return (f + i) * ((f - i) // 2 + 1) // 2 % 1000000007

def calc(f):
	if f <= 1:
		return f
	qtd = 2
	par = 2
	impar = 3
	sum = 1
	r = 1
	termina = False
	while True:
		if sum + qtd > f:
			qtd = f - sum
			termina = True
		r = (r + sumPA(par, par + qtd * 2 - 2)) % 1000000007
		par = par + qtd * 2
		sum += qtd
		qtd *= 2
		if termina:
			return r
		if sum + qtd > f:
			qtd = f - sum
			termina = True
		r = (r + sumPA(impar, impar + qtd * 2 - 2)) % 1000000007
		impar = impar + qtd * 2
		sum += qtd
		qtd *= 2
		if termina:
			return r
(n, m) = map(int, input().split(' '))
print((calc(m) - calc(n - 1)) % 1000000007)


(l, r) = map(int, input().split())
mod = 1000000007
s = 0
odd = 1
even = 2
isOdd = True
n = 1
i = 1
while l <= r:
	if i + n > l:
		if r == l:
			if isOdd:
				s = (s + odd + 2 * (l - i)) % mod
			else:
				s = (s + even + 2 * (l - i)) % mod
			l = r + 1
		elif r >= i + n:
			if isOdd:
				s = (s + (l - i + odd + (n - 1)) * (i + n - l)) % mod
			else:
				s = (s + (l - i + even + (n - 1)) * (i + n - l)) % mod
			l = i + n
		else:
			if isOdd:
				s = (s + (l - i + odd + (r - i)) * (r - l + 1)) % mod
			else:
				s = (s + (l - i + even + (r - i)) * (r - l + 1)) % mod
			l = r + 1
	i += n
	n <<= 1
	if isOdd:
		isOdd = False
		odd = (odd + n) % mod
	else:
		isOdd = True
		even = (even + n) % mod
print('%d' % s)


def solve(x):
	even = 0
	odd = 0
	i = 0
	ans = 0
	while x > 0:
		if i % 2 == 0:
			odd += min(x, 2 ** i) % m
		else:
			even += min(x, 2 ** i) % m
		x -= 2 ** i
		i += 1
	ans += even % m * (even % m + 1) % m
	ans += odd % m * (odd % m)
	return ans
m = 10 ** 9 + 7
(l, r) = map(int, input().split())
ans1 = solve(r)
ans2 = solve(l - 1)
print((ans1 % m - ans2 % m) % m)


modi = int(1000000000.0 + 7)

def love(lolly):
	cars = 1
	are = 1
	xre = 1
	yre = 2
	rre = 1
	while True:
		if are + cars - 1 >= lolly:
			if rre % 2 == 1:
				xre = xre + 2 * (lolly - are)
				yre -= 2
			else:
				yre = yre + 2 * (lolly - are)
				xre -= 2
			return (xre // 2 + 1) * (xre // 2 + 1) + (yre // 2 + 1) * (yre // 2)
		if rre % 2 == 1:
			xre += cars * 2
		else:
			yre += cars * 2
		are += cars
		cars *= 2
		rre += 1
(lre, rrl) = map(int, input().split())
plott = -1
if lre == 1:
	plott = 0
else:
	plott = love(lre - 1)
result = (love(rrl) - plott) % modi
print(result)


(l, r) = map(int, input().split())
ans = 0
while l <= r:
	ub = '1' * (len(bin(l)) - 2)
	even = len(ub)
	ub = min(int(ub, 2), r)
	fub = ub
	if even % 2 == 0:
		base = 1
		pos = l
		while pos > base:
			pos -= base
			ub -= base
			base *= 4
		ans += (pos * 2 + ub * 2) * (ub - pos + 1) // 2
	else:
		base = 2
		pos = l
		while pos > base:
			pos -= base
			ub -= base
			base *= 4
		ans += (pos * 2 - 1 + (ub * 2 - 1)) * (ub - pos + 1) // 2
	l = fub + 1
print(ans % 1000000007)


import pprint
max_value = 1000000000000000000
cache = []
cache.append((1, 1))
index = 0
while True:
	el = cache[index][0] * 2
	su = cache[index][1] + el
	cache.append((el, su))
	if su > max_value:
		break
	index += 1
(l, r) = list(map(int, input().split()))
if r == 1:
	print(1)
	exit(0)

def get_by_index(index):
	i = 0
	while cache[i][1] < index:
		i += 1
	(group, alle) = (0, 0)
	for j in range(0, i):
		if i % 2 == j % 2:
			group += cache[j][0]
		alle += cache[j][0]
	pos = group + index - alle
	sol = pos * 2 - (i + 1) % 2
	return sol

def prefix_solve(index):
	prev_index = 0
	while prev_index < len(cache) and cache[prev_index + 1][1] < index:
		prev_index += 1
	curr_element = get_by_index(index)
	prev_element = get_by_index(cache[prev_index][1])
	min_elemenet = min(curr_element, prev_element)
	max_elemenet = max(curr_element, prev_element)
	s1 = (1 + min_elemenet) * min_elemenet >> 1
	a1 = min_elemenet + 1
	a2 = max_elemenet
	n = (a2 - a1 >> 1) + 1
	s2 = (a1 + a2) * n >> 1
	sol = s1 + s2
	return sol
mod_value = 1000000007
sr = prefix_solve(r)
sl = 0 if l == 1 else prefix_solve(l - 1)
sol = (sr - sl) % mod_value
print(sol)


from math import *
import sys
import time
from statistics import *
from random import *
import bisect
sys.setrecursionlimit(10000000)

def f(a, b):
	ans = 0
	ans += a * a
	ans += b * b
	ans += b
	ans %= int(1000000000.0 + 7)
	return int(ans)

def ev(n):
	ans = [0, 0]
	x = 0
	u = 1
	flag = True
	while x <= n:
		x += u
		if x > n:
			x -= u
			break
		if flag:
			ans[0] += u
			flag = not flag
		else:
			ans[1] += u
			flag = not flag
		u *= 2
	if flag:
		ans[0] += n - x
	else:
		ans[1] += n - x
	return ans

def main():
	(l, r) = map(int, input().split())
	pl = ev(l - 1)
	pr = ev(r)
	ans = f(pr[0], pr[1]) - f(pl[0], pl[1])
	ans %= int(1000000000.0 + 7)
	print(int(ans))
main()


def mp():
	return map(int, input().split())

def f(n):
	if n < 2:
		return 0
	r = 1
	nc = 1
	ch = 0
	t = 0
	i = 2
	cnt = 1
	while cnt + 2 ** (i - 1) < n:
		if t == 0:
			left = ch + 2
			right = left + 2 ** i - 2
			r += (left + right) * 2 ** (i - 1) // 2
			ch = right
		else:
			left = nc + 2
			right = left + 2 ** i - 2
			r += (left + right) * 2 ** (i - 1) // 2
			nc = right
		cnt += 2 ** (i - 1)
		i += 1
		t = 1 - t
	if t == 0:
		left = ch + 2
	else:
		left = nc + 2
	ln = n - 2 ** (i - 1)
	right = left + 2 * (ln - 1)
	r += (left + right) * ln // 2
	return r
(l, r) = mp()
res = f(r + 1) - f(l)
print(res % (10 ** 9 + 7))


(l, r) = [int(s) for s in input().split(' ')]
big = 1000000007

def sumEven(k):
	return k * (k + 1) % big

def sumOdd(k):
	return (k * (k + 1) - k) % big

def f(k):
	i = 1
	l = 1
	s = 0
	count = [0, 0]
	while s + l <= k:
		s += l
		count[i % 2] += l
		i += 1
		l *= 2
	count[i % 2] += k - s
	return (sumEven(count[0]) + sumOdd(count[1])) % big
print((f(r) - f(l - 1) + big) % big)


(l, r) = map(int, input().split())
mod = 1000000007

def calc_sum(s, f, n):
	global l, r
	t = 'even' if s % 2 == 0 else 'odd'
	L = n + 1
	R = n + (f - s) // 2 + 1
	L = max(l, L)
	R = min(r, R)
	if L > R:
		return 0
	cnt = R - L + 1
	L = s + (L - n - 1) * 2
	R = s + (R - n - 1) * 2
	t_ans = L % mod * (cnt % mod) % mod
	t_ans %= mod
	t_ans += cnt % mod * (cnt - 1) % mod % mod
	t_ans %= mod
	return t_ans
p = 1
odd = 1
even = 2
ans = 0
while True:
	cnt_past = even // 2 - 1 + odd // 2
	if cnt_past >= r:
		break
	if p % 2 == 1:
		odd_end = odd + (1 << p) - 2
		ans += calc_sum(odd, odd_end, cnt_past)
		ans %= mod
		odd = odd_end + 2
	if p % 2 == 0:
		even_end = even + (1 << p) - 2
		ans += calc_sum(even, even_end, cnt_past)
		ans %= mod
		even = even_end + 2
	p += 1
print(ans)


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

def odd(n):
	return n * n % 1000000007

def even(n):
	return n * (n + 1) % 1000000007

def fun(n):
	i = 1
	turn = 1
	(oddcnt, evncnt) = (0, 0)
	while n >= i:
		if turn % 2:
			oddcnt += i
		else:
			evncnt += i
		n -= i
		i *= 2
		turn ^= 1
	if turn % 2:
		oddcnt += n
	else:
		evncnt += n
	return (odd(oddcnt) + even(evncnt)) % 1000000007
print((fun(r) - fun(l - 1)) % 1000000007)


(l, r) = map(int, input().split())
ste = [1, 2]
for i in range(2, 70):
	ste.append(ste[i - 1] * 2)
sa = [1, 2]
for i in range(2, 70):
	sa.append(sa[i - 2] + ste[i - 2] * 2)
(stl, rst) = (0, 0)
for i in range(0, 70):
	if ste[i] > l:
		stl = i
		break
for i in range(0, 70):
	if ste[i] > r:
		rst = i - 1
		break
if stl > rst:
	qk = sa[stl - 1] + (l - ste[stl - 1]) * 2
	qn = r - l
	print((qk + qn) * (qn + 1) % 1000000007)
else:
	qk = sa[stl - 1] + (l - ste[stl - 1]) * 2
	qn = ste[stl] - 1 - l
	c = (qk + qn) * (qn + 1)
	for i in range(stl, rst):
		c += (sa[i] + ste[i] - 1) * ste[i]
	c += (sa[rst] + r - ste[rst]) * (r - ste[rst] + 1)
	print(c % 1000000007)


from math import log

def sum1(b):
	if b == 0:
		return 0
	dhap = int(log(b, 2))
	extra = b - 2 ** dhap + 1
	even = odd = 0
	for i in range(dhap):
		if i % 2 == 0:
			odd += 2 ** i
		else:
			even += 2 ** i
	if dhap % 2 == 1:
		even += extra
	else:
		odd += extra
	return odd * odd + even * (even + 1)
(a, b) = map(int, input().split())
print((sum1(b) - sum1(a - 1)) % (10 ** 9 + 7))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')
mod = 10 ** 9 + 7
INF = float('inf')
from math import factorial, sqrt, ceil, floor
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	(l, r) = RL()

	def c(num):
		i = 0
		od = ev = 0
		tag = 0
		while num > 0:
			if tag:
				ev = (ev + min(num, 2 ** i)) % mod
			else:
				od = (od + min(num, 2 ** i)) % mod
			tag ^= 1
			num -= 2 ** i
			i += 1
		(a, b) = (1 + (od - 1) * 2, 2 + (ev - 1) * 2)
		(so, se) = ((1 + a) * od // 2, (2 + b) * ev // 2)
		return (so + se) % mod
	print((c(r) - c(l - 1)) % mod)
main()


def log2(n):
	cnt = 0
	n = n >> 1
	while n > 0:
		n = n >> 1
		cnt += 1
	return cnt
(l, r) = input().split()
l = int(l)
r = int(r)
n = int(log2(l))
s = n % 2
el = ol = 0
if s != 0:
	if n > 1:
		el = 2 * (2 ** (n - 1) - 1) // 3
	ol = (2 ** (n + 1) - 1) // 3
	el += l - 2 ** n
else:
	if n != 0:
		ol = (2 ** n - 1) // 3
		el = 2 * (2 ** n - 1) // 3
	ol += l - 2 ** n
n = int(log2(r))
s = n % 2
er = ors = 0
if s != 0:
	if n > 1:
		er = 2 * (2 ** (n - 1) - 1) // 3
	ors = (2 ** (n + 1) - 1) // 3
	er += r - 2 ** n + 1
else:
	if n != 0:
		ors = (2 ** n - 1) // 3
		er = 2 * (2 ** n - 1) // 3
	ors += r - 2 ** n + 1
a = ol * ol
b = el * (el + 1)
c = ors * ors
d = er * (er + 1)
print((d + c - a - b) % (10 ** 9 + 7))


INF = int(1000000000.0 + 7)

def get_sum(pos):
	ans = 0
	next_ele = {1: 2, 0: 1}
	cnt = 0
	while pos > 0:
		number_of_ele = min(1 << cnt, pos)
		pos -= number_of_ele
		number_of_ele %= INF
		switch = cnt & 1
		next_sum = (next_ele[switch] + number_of_ele - 1) * number_of_ele
		next_sum %= INF
		ans += next_sum
		ans %= INF
		next_ele[switch] += number_of_ele * 2
		next_ele[switch] %= INF
		cnt += 1
	return int(ans)
(l, r) = list(map(int, input().split()))
print(int((get_sum(r) - get_sum(l - 1) % INF + INF) % INF))


from math import *

def input_ints():
	return list(map(int, input().split()))
M = 1000000007

def prefix_sum(n):
	a = floor(log2(n))
	b = n - 2 ** a
	n_even_groups = a // 2
	n_odd_groups = a - n_even_groups
	n_odds = (1 - 4 ** n_odd_groups) // -3
	n_evens = 2 * (1 - 4 ** n_even_groups) // -3
	if n_odd_groups == n_even_groups:
		n_odds += b
	else:
		n_evens += b
	return n_odds ** 2 + n_evens * (n_evens + 1)
(l, r) = input_ints()
ans = prefix_sum(r + 1) - prefix_sum(l)
print(ans % M)


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

def get(n):
	oe = [0, 0]
	c = i = 1
	w = 0
	while i <= n:
		j = min(i + c, n + 1)
		oe[w] += j - i
		i = j
		c *= 2
		w ^= 1
	return oe[0] * oe[0] + oe[1] * (1 + oe[1])
print((get(r) - get(l - 1)) % (10 ** 9 + 7))


import math
mod = 1000000007

def summer(a):
	if a == 0:
		return 0
	terms = int(math.log(a, 2))
	odd = 0
	even = 0
	ein = 1
	for i in range(0, terms + 1, 2):
		even = (ein + even) % mod
		ein = ein * 4 % mod
	oin = 2
	for i in range(1, terms + 1, 2):
		odd = (odd + oin) % mod
		oin = oin * 4 % mod
	if terms % 2 == 0:
		even = (even + a - int(pow(2, terms + 1)) + 1) % mod
	else:
		odd = (odd + a - int(pow(2, terms + 1)) + 1) % mod
	ans = even * even % mod
	ans = (ans + odd * (odd + 1)) % mod
	return ans
inp = input()
l = int(inp.split(' ')[0])
r = int(inp.split(' ')[1])
ans = int((summer(r) - summer(l - 1)) % mod)
print(ans)


(l, r) = map(int, input().split())
L = R = LL = RR = 0
mod = 1000000007
while True:
	if 1 << L > l:
		break
	L += 1
while True:
	if (1 << R) - 1 >= r:
		break
	R += 1
RR = (1 << R) - 1
sum = 0
for i in range(L, R + 1):
	if i % 2 == 1:
		sum += 2 ** (i - 1) * (-2 + 2 ** i + 3 * 2 ** (i - 1)) // 3
	else:
		sum += 2 ** (i - 1) * (-1 + 2 ** i + 3 * 2 ** (i - 1)) // 3
if L % 2 == 1:
	LL = 2 * (4 ** ((L - 1) // 2) - 1) // 3 + 1
else:
	LL = 4 * (4 ** (L // 2 - 1) - 1) // 3 + 2
if R % 2 == 1:
	RR = 2 * (4 ** ((R + 1) // 2) - 1) // 3 - 1
else:
	RR = 4 * (4 ** (R // 2) - 1) // 3
k = l - (1 << L - 1)
sum -= k * (k - 1 + LL)
k = (1 << R) - 1 - r
sum -= k * (-k + 1 + RR)
print(sum % mod)


p = 1000000007

def get(x):
	if x == 0:
		return 0
	sum = 0
	l = 1
	r = 1
	p1 = 1
	p2 = 1
	i = 1
	cnt = 1
	while l < 1000000000000000000:
		r = l + i
		if cnt % 2:
			if x >= l and x < r:
				sum = (sum + (x - l + 1) % p * (p1 % p * 2 % p + (x - l + 1) % p - 2 + p) % p) % p
				break
			else:
				sum = (sum + i % p * (p1 % p * 2 % p + i - 2 + p) % p) % p
			p1 = p1 + i
		else:
			if x >= l and x < r:
				sum = (sum + (x - l + 1) % p * (p2 % p * 2 % p + (x - l + 1) % p - 1 + p) % p) % p
				break
			else:
				sum = (sum + i % p * (p2 % p * 2 % p + i % p - 1 + p) % p) % p
			p2 = p2 + i
		l = r
		i = i << 1
		cnt = cnt + 1
	return sum
(l, r) = input().split(' ')
l = int(l)
r = int(r)
ans = (get(r) - get(l - 1) + p) % p
print(ans)


import sys
sys_input = sys.stdin.readline

def si():
	return sys_input().rstrip()

def ii():
	return int(si())

def sti():
	return si().split()

def iti():
	return map(int, sti())

def sli():
	return list(si())

def ili():
	return list(iti())

def edge_num(n):
	parity = n % 2
	if parity == 1:
		left_index = (4 ** ((n - 1) // 2) + 2) // 3
		right_index = (4 ** ((n + 1) // 2) - 1) // 3
		return [i * 2 - 1 for i in [left_index, right_index]]
	else:
		left_index = (2 ** n + 2) // 3
		right_index = (2 ** (n + 2) - 4) // 3
		return [left_index, right_index]

def whole_sum(n):
	(left_num, right_num) = edge_num(n)
	return (left_num + right_num) * 2 ** (n - 2)

def left_sum(n, l):
	(left_num, right_num) = edge_num(n)
	l_index = l - 2 ** (n - 1) + 1
	l_num = left_num + (l_index - 1) * 2
	return (l_num + right_num) * (2 ** (n - 1) - l_index + 1) // 2

def right_sum(n, r):
	(left_num, _) = edge_num(n)
	r_index = r - 2 ** (n - 1) + 1
	r_num = left_num + (r_index - 1) * 2
	return (left_num + r_num) * r_index // 2

def left_right_sum(n, l, r):
	(left_num, _) = edge_num(n)
	l_index = l - 2 ** (n - 1) + 1
	l_num = left_num + (l_index - 1) * 2
	r_num = l_num + (r - l) * 2
	return (l_num + r_num) * (r - l + 1) // 2

def main():
	l_row = len(bin(L)) - 2
	r_row = len(bin(R)) - 2
	result = 0
	if l_row == r_row:
		result += left_right_sum(l_row, L, R) % MOD
	else:
		for i in range(l_row + 1, r_row):
			result += whole_sum(i) % MOD
		result += left_sum(l_row, L) % MOD
		result += right_sum(r_row, R) % MOD
	print(result % MOD)
(L, R) = iti()
MOD = 10 ** 9 + 7
main()


(n, m) = map(int, input().split())
a = 0
b = 0
k = 0
i = 0
while a + b + 2 ** i <= m:
	if i % 2 == 0:
		a += 2 ** i
	else:
		b += 2 ** i
	i += 1
if i % 2 != 0:
	b += m - (a + b)
else:
	a += m - (a + b)
s1 = a * a + b * (b + 1)
a = 0
b = 0
k = 0
i = 0
m = n - 1
while a + b + 2 ** i <= m:
	if i % 2 == 0:
		a += 2 ** i
	else:
		b += 2 ** i
	i += 1
if i % 2 != 0:
	b += m - (a + b)
else:
	a += m - (a + b)
s2 = a * a + b * (b + 1)
print((s1 - s2) % 1000000007)


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()


mod = 10 ** 9 + 7
import math
s = list(map(int, input().split()))
(a, b) = (int(math.log(s[0], 2)), int(math.log(s[1], 2)))
f = [1]
for i in range(1, b + 1):
	if i & 1 == 0:
		f.append(2 * f[i - 1] - 1)
	else:
		f.append(2 * f[i - 1])
res = 0
m = a
while a < b:
	res += f[a] * 2 ** a % mod + (2 ** a - 1) * 2 ** a % mod
	a += 1
a = m
(x, y) = (s[0] - 2 ** a, s[1] - 2 ** b)
res -= f[a] * x % mod + x * (x - 1) % mod
res += f[b] * (y + 1) % mod + y * (y + 1) % mod
print(res % mod)


from math import log, floor
MOD = floor(1000000000.0 + 7)

def sum_of(n):
	if n == 0:
		return 0
	i = floor(log(n + 1) / log(2))
	len_1 = (4 ** ((i + 1) // 2) - 1) // 3
	len_2 = 2 * (4 ** (i // 2) - 1) // 3
	if i % 2 == 0:
		len_1 += n - 2 ** i + 1
	else:
		len_2 += n - 2 ** i + 1
	len_1 %= MOD
	len_2 %= MOD
	sum_of_1 = (1 + 1 + 2 * (len_1 - 1)) * len_1 // 2
	sum_of_2 = (2 + 2 + 2 * (len_2 - 1)) * len_2 // 2
	return (sum_of_1 + sum_of_2) % MOD
(n, m) = list(map(int, input().split()))
print((sum_of(m) - sum_of(n - 1) + MOD) % MOD)


M = 1000000007
import math

def func(a):
	if a == 0:
		return 0
	b = math.log2(a)
	b = int(b)
	o = 0
	e = 0
	for i in range(b):
		if i % 2 == 0:
			o += 1 << i
		else:
			e += 1 << i
	if b % 2 == 0:
		o += a - (1 << b) + 1
	else:
		e += a - (1 << b) + 1
	ans = 0
	ans += o * o
	ans += e * (e + 1)
	return ans
(l, r) = map(int, input().split())
ans = (func(r) - func(l - 1)) % M
print(ans)


def range_intersect(r1, r2):
	return [max(r1[0], r2[0]), min(r1[1], r2[1])]

def calc(pow2, log_pow2, offset, l):
	num_before = offset
	while pow2 >= 4:
		pow2 >>= 2
		num_before += pow2
	start = log_pow2 % 2 + 1 + num_before * 2
	end = start + 2 * (l - 1)
	return (start + end) * l // 2
(l, r) = map(int, input().strip().split(' '))
res = 0
pow2 = 1
log_pow2 = 0
while 2 * pow2 <= l:
	pow2 *= 2
	log_pow2 += 1
res = 0
while True:
	end = 2 * pow2 - 1
	rng = range_intersect([l, r], [pow2, end])
	rng_len = rng[1] - rng[0] + 1
	if rng_len <= 0:
		break
	res += calc(pow2, log_pow2, rng[0] - pow2, rng_len)
	pow2 *= 2
	log_pow2 += 1
print(res % 1000000007)


import sys
input = lambda : sys.stdin.readline().strip()
(l, r) = [int(x) for x in input().split()]
M = 10 ** 9 + 7

def T(n):
	return n * (n + 1) // 2

def f(n):
	total = 0
	s = 0
	a = [(1, 1), (2, 2)]
	for (start, terms) in a:
		new_terms = min(terms, n - total)
		total += new_terms
		s += start * new_terms % M + 2 * T(new_terms - 1) % M
		s %= M
		a.append((start + 2 * terms, terms * 4))
		if total >= n:
			break
	return s
print((f(r) - f(l - 1)) % M)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def func(x):
	power = 0
	copy = x
	even = 0
	odd = 0
	while x > 0:
		if power % 2 == 0:
			odd += min(2 ** power, x)
		else:
			even += min(2 ** power, x)
		x -= min(x, 2 ** power)
		power += 1
	c1 = even % mod * ((even + 1) % mod)
	c2 = odd % mod * (odd % mod)
	r = c1 + c2
	return (r, even, odd)
(l, r) = map(int, input().split())
res = (func(r)[0] - func(l - 1)[0]) % mod
print(res)


import sys

def input():
	return sys.stdin.readline().rstrip()
MOD = int(1000000000.0 + 7)

def rangesum(idx):
	assert idx >= 0
	(evenset, oddset) = (0, 0)
	addition = 1
	sign = 1
	while evenset + oddset < idx:
		if sign == 0:
			evenset += addition
			addition *= 2
		else:
			oddset += addition
			addition *= 2
		sign ^= 1
	sign ^= 1
	if sign == 0:
		over_addition = evenset + oddset - idx
		evenset -= over_addition
	else:
		over_addition = evenset + oddset - idx
		oddset -= over_addition
	assert oddset + evenset == idx
	return oddset * oddset + evenset * (evenset + 1)

def slv():
	(l, r) = map(int, input().split())
	ans = rangesum(r) - rangesum(l - 1)
	print(ans % MOD)
	return

def main():
	t = 1
	for i in range(t):
		slv()
	return
main()


def f(x):
	curr = 1
	arr = [0, 0]
	which = 0
	while x > 0:
		if curr >= x:
			arr[which] += x
			break
		arr[which] += curr
		x -= curr
		which ^= 1
		curr *= 2
	num1 = (2 + (arr[0] - 1) * 2) * arr[0] // 2
	num1 %= 1000000007
	num2 = (4 + (arr[1] - 1) * 2) * arr[1] // 2
	num2 %= 1000000007
	return num1 + num2
l = input().split()
L = int(l[0])
R = int(l[1])
z = f(R) - f(L - 1)
print(z % 1000000007)


import math

def log(x):
	return math.log(x) / math.log(2)

def getsum(x):
	if x == 0:
		return 0
	bits = int(math.floor(log(x)) + 1)
	even_count = 0
	odd_count = 0
	if bits % 2 == 0:
		c = 0
		for i in range(1, bits - 1, 2):
			c += 2 ** i
		c += x - 2 ** (bits - 1) + 1
		even_count = c
		odd_count = x - c
	else:
		c = 0
		for i in range(0, bits - 1, 2):
			c += 2 ** i
		c += x - 2 ** (bits - 1) + 1
		odd_count = c
		even_count = x - c
	return (even_count ** 2 + even_count + odd_count ** 2) % 1000000007
x = input()
l = int(x[0:x.find(' ')])
r = int(x[x.find(' ') + 1:])
print((getsum(r) - getsum(l - 1) + 1000000007) % 1000000007)


import math

def solve(n):
	if n == 0:
		return 0
	ans = 0
	p = int(math.log2(n + 1)) - 1
	X = (pow(4, p // 2 + 1, MOD) - 1) * pow(3, MOD - 2, MOD) % MOD
	Y = 2 * (pow(4, (p - 1) // 2 + 1, MOD) - 1) * pow(3, MOD - 2, MOD) % MOD
	ans += pow(X, 2, MOD) + Y * (Y + 1) % MOD
	D = n - (2 ** (p + 1) - 1)
	if p % 2 == 0:
		ans += (2 * Y * D + D * (D + 1)) % MOD
	else:
		ans += (2 * X * D + D * (D + 1) - D) % MOD
	return ans
MOD = 10 ** 9 + 7
(l, r) = [int(item) for item in input().split()]
print((solve(r) - solve(l - 1)) % MOD)


def Sum(count):
	odd = 1
	even = 2
	size = 1
	take_odd = True
	while count > 0:
		to_take = min(size, count)
		if take_odd:
			odd += to_take * 2
		else:
			even += to_take * 2
		count -= to_take
		take_odd = not take_odd
		size *= 2
	res = (1 + odd - 2) * (odd // 2) // 2
	res += (2 + even - 2) * (even // 2 - 1) // 2
	return res

def main():
	MOD = 1000000007
	(left, right) = (int(tok) for tok in input().split())
	res = Sum(right) - Sum(left - 1)
	res %= MOD
	while res < 0:
		res += MOD
	print(res)
main()


(l, r) = map(int, input().split())
i = 1
even = 0
a = 0
b = 0
c = 0
d = 0
sums = 0
ol = 0
ori = 0
el = 0
er = 0
while i <= r:
	if even:
		b += i
		if i * 2 < l:
			d = b
		if i * 2 > l and i <= l:
			el = l - i + d
			ol = a
		if i * 2 > r and i <= r:
			er = b - (i * 2 - r) + 1
			ori = a
	else:
		a += i
		if i * 2 < l:
			c = a
		if i * 2 > l and i <= l:
			ol = l - i + c
			el = b
		if i * 2 > r and i <= r:
			er = b
			ori = a - (i * 2 - r) + 1
	i = i * 2
	even ^= 1
g = ori * ori - ol * ol
k = er * (er + 1) - el * (el + 1)
sums = ori * ori - ol * ol + er * (er + 1) - el * (el + 1)
sums = sums % 1000000007
print(sums)


MOD = int(1000000000.0 + 7)

def SON(n):
	(e, o, p, t) = (0, 0, 1, False)
	while n > 0:
		if t:
			e += min(p, n)
		else:
			o += min(p, n)
		n -= p
		p *= 2
		t = not t
	return e * (e + 1) + o * o
(l, r) = map(int, input().split())
print((SON(r) - SON(l - 1)) % MOD)


(l, r) = map(int, input().split())
mod = 1000000007
k = c = 1
r -= 1
l -= 2
s = 0
(x, y) = (1, 2)
while r > 0:
	if c:
		s += (2 * x + 2 * (k - 1)) * k
		x += 2 * k
	else:
		s += (2 * y + 2 * (k - 1)) * k
		y += 2 * k
	c ^= 1
	k <<= 1
	r -= k
	s %= mod
if c:
	s += (2 * x + 2 * (r + k - 1)) * (r + k)
else:
	s += (2 * y + 2 * (r + k - 1)) * (r + k)
k = c = 1
(x, y) = (1, 2)
s %= mod
while l > 0:
	if c:
		s -= (2 * x + 2 * (k - 1)) * k
		x += 2 * k
	else:
		s -= (2 * y + 2 * (k - 1)) * k
		y += 2 * k
	k <<= 1
	l -= k
	c ^= 1
	s %= mod
if c:
	s -= (2 * x + 2 * (l + k - 1)) * (l + k)
else:
	s -= (2 * y + 2 * (l + k - 1)) * (l + k)
print(pow(2, mod - 2, mod) * s % mod)


mod = 10 ** 9 + 7

def cnt(num):
	if num == 0:
		return 0
	order = 0
	for i in range(1, 1000):
		if 2 ** (i - 1) - 1 < num <= 2 ** i - 1:
			order = i
			break
	(odd, even) = (0, 0)
	for i in range(order):
		if i % 2 == 0:
			odd += 1 << i
		else:
			even += 1 << i
	overget = 2 ** order - 1 - num
	if order % 2 == 0:
		even -= overget
	elif order % 2 != 0:
		odd -= overget
	return odd ** 2 + even * (even + 1)

def main():
	(l, r) = map(int, input().split())
	ans = cnt(r) - cnt(l - 1)
	print(ans % mod)
	return
main()


def calc(n):
	if n == 0:
		return 0
	res = 1
	turn = 0
	(oddsum, evensum) = (0, 0)
	while res <= n:
		if not turn:
			oddsum += res
			oddsum %= mod
		else:
			evensum += res
			evensum %= mod
		n -= res
		res *= 2
		turn = 1 - turn
	if n > 0:
		if not turn:
			oddsum += n
		else:
			evensum += n
	oddsum %= mod
	evensum %= mod
	return pow(oddsum, 2, mod) + pow(evensum, 2, mod) + evensum
mod = 10 ** 9 + 7
(l, r) = map(int, input().split())
print((calc(r) % mod - calc(l - 1) % mod) % mod)


from math import log2, floor

def f3(a):
	if a == 0:
		return 0
	elif a == 1:
		return 1
	elif a == 2:
		return 3
	elif a == 3:
		return 7
	return -1
(l, r) = map(int, input().split())
(ln, rn) = (f3(l), f3(r))
if ln != -1 and rn != -1:
	print(rn - f3(l - 1))
	quit()
if rn == -1 and ln != -1:
	x = j = floor(log2(r))
	j += 1
	su = 0
	if j % 2 == 0:
		while j >= 2:
			su += 2 ** j
			j -= 2
	else:
		while j >= 3:
			su += 2 ** j
			j -= 2
		su += 1
	ij = 2 ** (x + 1) - 1
	rn = su - 2 * (ij - r)
	suu = 0
	if rn % 2 == 0:
		suu = rn // 2 * (rn // 2 + 1)
		ot = (su - 2) // 2
		suu += ((ot + 1) // 2) ** 2
	else:
		n = (rn + 1) // 2
		suu = n ** 2
		ot = (su - 1) // 2
		suu += ot // 2 * (ot // 2 + 1)
	print((suu - f3(l - 1)) % int(1000000000.0 + 7))
	quit()
else:
	x = j = floor(log2(r))
	j += 1
	su = 0
	if j % 2 == 0:
		while j >= 2:
			su += 2 ** j
			j -= 2
	else:
		while j >= 3:
			su += 2 ** j
			j -= 2
		su += 1
	ij = 2 ** (x + 1) - 1
	rn = su - 2 * (ij - r)
	suu1 = 0
	if rn % 2 == 0:
		suu1 = rn // 2 * (rn // 2 + 1)
		ot = (su - 2) // 2
		suu1 += ((ot + 1) // 2) ** 2
	else:
		n = (rn + 1) // 2
		suu1 = n ** 2
		ot = (su - 1) // 2
		suu1 += ot // 2 * (ot // 2 + 1)
	x = j = floor(log2(l))
	j += 1
	su = 0
	if j % 2 == 0:
		while j >= 2:
			su += 2 ** j
			j -= 2
	else:
		while j >= 3:
			su += 2 ** j
			j -= 2
		su += 1
	ij = 2 ** (x + 1) - 1
	rn = su - 2 * (ij - l)
	suu2 = 0
	if rn % 2 == 0:
		suu2 = rn // 2 * (rn // 2 + 1)
		ot = (su - 2) // 2
		suu2 += ((ot + 1) // 2) ** 2
	else:
		n = (rn + 1) // 2
		suu2 = n ** 2
		ot = (su - 1) // 2
		suu2 += ot // 2 * (ot // 2 + 1)
	print((suu1 - suu2 + rn) % int(1000000000.0 + 7))


m = 10 ** 18
t = 1
a = []
temp = 1
a.append([t, temp])
odd = 1
even = 0
for i in range(1, 61):
	if (i + 1) % 2 != 0:
		t = t * 2
		a.append([t, 1 + odd * 2])
		odd += t
	else:
		t = t * 2
		a.append([t, 2 + even * 2])
		even += t
(l, r) = map(int, input().split())
sumi = 0
alpha = r
hell = 10 ** 9 + 7
for i in range(61):
	if alpha >= a[i][0]:
		sumi += (2 * a[i][1] + (a[i][0] - 1) * 2) * a[i][0] // 2
		alpha -= a[i][0]
		if alpha == 0:
			break
	else:
		sumi += alpha * (2 * a[i][1] + (alpha - 1) * 2) // 2
		aplha = 0
		break
right = sumi
alpha = l
sumi = 0
for i in range(61):
	if alpha >= a[i][0]:
		sumi += (2 * a[i][1] + (a[i][0] - 1) * 2) * a[i][0] // 2
		alpha -= a[i][0]
		last = a[i][1] + (a[i][0] - 1) * 2
		if alpha == 0:
			break
	else:
		sumi += alpha * (2 * a[i][1] + (alpha - 1) * 2) // 2
		last = a[i][1] + (alpha - 1) * 2
		alpha = 0
		break
left = sumi
print((right - left + last) % hell)


mod = 1000000007
(l, r) = map(int, input().split(' '))

def f(v):
	sum = 0
	a = 1
	b = 2
	cnt = 1
	while v > 0:
		tcnt = min(v, cnt)
		sum = (sum + (a + tcnt - 1) * tcnt) % mod
		a = a + 2 * tcnt
		cnt = cnt * 2
		(a, b) = (b, a)
		v = v - tcnt
	return sum
print((f(r) - f(l - 1) + mod) % mod)


import math
M = 10 ** 9 + 7
(l, r) = map(int, input().split())
tri = lambda x: x * (x + 1)

def solve(x):
	if x < 4:
		return [0, 1, 3, 7][x]
	g = int(math.log(x, 2))
	i = x - 2 ** g + 1
	suma = 0
	if g % 2 == 0:
		n = (2 ** g - 1) // 3
		suma = tri(2 * n) % M
		suma += (n + i) ** 2 % M
	else:
		n = (2 ** (g + 1) - 1) // 3
		n_p = 2 * n - 2 ** g
		suma = n ** 2 % M
		suma += tri(n_p + i) % M
	return suma % M
print((solve(r) - solve(l - 1)) % M)


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) = map(int, input().split())
print((calc(r) - calc(l - 1)) % (10 ** 9 + 7))


M = 1000000007

def s_sum(d):
	if d < 1:
		return 0
	s = [0, 0]
	p = 1
	t = 0
	while p <= d:
		s[t] += p
		d -= p
		p *= 2
		t = 1 - t
	s[t] += d
	nodd = s[0]
	neven = s[1]
	return (nodd * nodd % M + neven * (neven + 1) % M) % M
(l, r) = map(int, input().split())
ans = (s_sum(r) - s_sum(l - 1)) % M
ans += M
ans %= M
print(ans)


def suma(x):
	mocnina = 1
	modulo = 1000000007
	parnych = 0
	neparnych = 0
	par = 0
	while x > 0:
		if par:
			parnych += min(mocnina, x)
		else:
			neparnych += min(mocnina, x)
		x -= mocnina
		mocnina *= 2
		par += 1
		par %= 2
	return parnych * (parnych + 1) % modulo + neparnych * neparnych % modulo
(l, r) = [int(x) for x in input().split()]
modulo = 1000000007
vysl = (suma(r) + modulo - suma(l - 1)) % modulo
print(vysl)


import math

def Solve(x):
	if x == 0:
		return 0
	stage = int(math.floor(math.log(x, 2)))
	odd = math.ceil(stage / 2)
	even = math.floor(stage / 2)
	even_terms = 2 * (pow(4, even) - 1) // 3
	odd_terms = (pow(4, odd) - 1) // 3
	total = even_terms + odd_terms
	if (stage + 1) % 2 == 0:
		even_terms += x - total
	else:
		odd_terms += x - total
	sum_even_terms = even_terms * (1 + even_terms)
	sum_odd_terms = odd_terms * odd_terms
	return (sum_even_terms % 1000000007 + sum_odd_terms % 1000000007) % 1000000007

def main():
	(l, r) = map(int, input().split())
	print((Solve(r) - Solve(l - 1)) % 1000000007)
main()


def oddSum(n):
	return n ** 2

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

def getOddEvenCount(n):
	cur = 1
	total = 0
	(odd, even) = (0, 0)
	isOdd = False
	while total + cur <= n:
		isOdd = not isOdd
		if isOdd:
			odd += cur
		else:
			even += cur
		total += cur
		cur *= 2
	if isOdd:
		even += n - total
	else:
		odd += n - total
	return (odd, even)
(l, r) = map(int, input().split())
modn = int(1000000000.0 + 7)
(odd_l, even_l) = getOddEvenCount(l - 1)
(odd_r, even_r) = getOddEvenCount(r)
res = oddSum(odd_r) + evenSum(even_r) - oddSum(odd_l) - evenSum(even_l)
print(res % modn)


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):
	(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)


(l, r) = input().split()
l = int(l)
r = int(r)
MOD = int(1000000000.0 + 7)

def calc(l, len):
	lst = l + (len - 1) * 2
	return (l + lst) * len // 2 % MOD

def solve(l):
	s1 = 1
	s2 = 2
	now = 1
	start = 1
	ans = 0
	nk = 0
	while True:
		if nk == 0:
			if start + now <= l:
				ans += calc(s1, now)
				ans %= MOD
				s1 = s1 + now * 2
			else:
				ans += calc(s1, l - start)
				ans %= MOD
				break
		elif start + now <= l:
			ans += calc(s2, now)
			ans %= MOD
			s2 = s2 + now * 2
		else:
			ans += calc(s2, l - start)
			ans %= MOD
			break
		start += now
		now *= 2
		nk = 1 - nk
	return ans
print((solve(r + 1) - solve(l) + 2 * MOD) % MOD)


import math
(l, r) = [int(x) for x in input().split(' ')]
i = l
s = 0
while i <= r:
	n = math.floor(math.log(i, 2))
	if n % 2 == 0:
		n = (n + 2) // 2
		start = pow(2, 2 * n - 1)
		end = pow(2, 2 * n - 1) - 1
		ts = (pow(4, n - 1) - 1) // 3
		if pow(2, 2 * n - 2) < i:
			ts = ts + i - pow(2, 2 * n - 2)
		if end <= r:
			te = (pow(4, n) - 1) // 3
		else:
			te = r - i + 1 + ts
		s += (te * te % 1000000007 - ts * ts % 1000000007) % 1000000007
		i = end + 1
	else:
		n = (n + 1) // 2
		start = pow(2, 2 * n - 1)
		end = pow(2, 2 * n) - 1
		ts = 2 * (pow(4, n - 1) - 1) // 3
		if start < i:
			ts = ts + i - pow(2, 2 * n - 1)
		if end <= r:
			te = 2 * (pow(4, n) - 1) // 3
		else:
			te = r - i + 1 + ts
		s += ((te * te + te) % 1000000007 - (ts * ts + ts) % 1000000007) % 1000000007
		i = end + 1
	s = s % 1000000007
print(s % 1000000007)


__version__ = '0.1'
__date__ = '2019-04-18'
import sys
from bisect import bisect

def find_sum(l, r):
	(l, r) = (l - 1, r - 1)
	expo_twos = [pow(2, i) for i in range(60)]
	accum_twos = [0]
	for (i, two) in enumerate(expo_twos):
		accum_twos.append(two + accum_twos[-1])
	idx = bisect(accum_twos, l)
	if idx > 2:
		if idx % 2 == 1:
			group_first = 2 * (sum(accum_twos[idx - 2:None:-2]) - sum(accum_twos[idx - 3:None:-2]) - 1) + 3
			prev_group_last = 2 * (sum(accum_twos[idx - 1:None:-2]) - sum(accum_twos[idx - 2:None:-2]))
			diff = l - accum_twos[idx - 1] - 1
			last_elem = group_first + diff * 2
			to_be_subtracted = pow(last_elem + 1, 2) // 4 + prev_group_last * (prev_group_last + 2) // 4
		else:
			group_first = 2 * (sum(accum_twos[idx - 2:None:-2]) - sum(accum_twos[idx - 3:None:-2])) + 2
			prev_group_last = 2 * (sum(accum_twos[idx - 1:None:-2]) - sum(accum_twos[idx - 2:None:-2])) - 1
			diff = l - accum_twos[idx - 1] - 1
			last_elem = group_first + diff * 2
			to_be_subtracted = last_elem * (last_elem + 2) // 4 + pow(prev_group_last + 1, 2) // 4
	else:
		to_be_subtracted = (0, 1, 3, 7)[l]
	idy = bisect(accum_twos, r)
	if idy > 2:
		if idy % 2 == 1:
			group_first = 2 * (sum(accum_twos[idy - 2:None:-2]) - sum(accum_twos[idy - 3:None:-2]) - 1) + 3
			prev_group_last = 2 * (sum(accum_twos[idy - 1:None:-2]) - sum(accum_twos[idy - 2:None:-2]))
			diff = r - accum_twos[idy - 1]
			last_elem = group_first + diff * 2
			to_subtract = pow(last_elem + 1, 2) // 4 + prev_group_last * (prev_group_last + 2) // 4
		else:
			group_first = 2 * (sum(accum_twos[idy - 2:None:-2]) - sum(accum_twos[idy - 3:None:-2])) + 2
			prev_group_last = 2 * (sum(accum_twos[idy - 1:None:-2]) - sum(accum_twos[idy - 2:None:-2])) - 1
			diff = r - accum_twos[idy - 1]
			last_elem = group_first + diff * 2
			to_subtract = last_elem * (last_elem + 2) // 4 + pow(prev_group_last + 1, 2) // 4
	else:
		to_subtract = (1, 3, 7)[r]
	return to_subtract - to_be_subtracted

def main(argv=None):
	(l, r) = map(int, input().split())
	print(find_sum(l, r) % 1000000007)
	return 0
STATUS = main()
sys.exit(STATUS)


from math import log2
(l, r) = [int(x) for x in input().split()]
l_stage = int(log2(l)) + 1
l_odd_num = 0
l_even_num = 0
l_com_stage = l_stage - 1
if l_com_stage % 2 != 0:
	l_even_num += l - (2 ** l_com_stage - 1) - 1
	l_com_stage -= 1
	l_odd_num += 2 ** l_com_stage
else:
	l_odd_num += l - (2 ** l_com_stage - 1) - 1
l_total_num = 2 ** l_com_stage - 1
l_odd_num += l_total_num // 3
l_even_num += l_total_num * 2 // 3
r_stage = int(log2(r)) + 1
r_odd_num = 0
r_even_num = 0
r_com_stage = r_stage - 1
if r_com_stage % 2 != 0:
	r_even_num += r - (2 ** r_com_stage - 1)
	r_com_stage -= 1
	r_odd_num += 2 ** r_com_stage
else:
	r_odd_num += r - (2 ** r_com_stage - 1)
r_total_num = 2 ** r_com_stage - 1
r_odd_num += r_total_num // 3
r_even_num += r_total_num * 2 // 3
sum = (r_odd_num ** 2 - l_odd_num ** 2) % 1000000007 + (r_even_num * (r_even_num + 1) - l_even_num * (l_even_num + 1)) % 1000000007
print(sum % 1000000007)


def in_int():
	return int(input())

def in_list():
	return [int(x) for x in input().split()]
(l, r) = in_list()

def info(p):
	s = str(p)[::-1]
	i = 0
	(odd_num, even_num) = (0, 0)
	while s[i] == 0:
		i += 1
	if i % 2 == 0:
		even = True
		p = 2 ** i
	else:
		even = False
md = 10 ** 9 + 7

def get_sum(p):
	if p == 0:
		return 0
	sum = 0
	l = [1, 2]
	s = [1, 2]
	e = [1, 4]
	pp = [1, 2]
	c = 0
	while pp[c] + l[c] - 1 <= p:
		sum += l[c] * (e[c] + s[c]) // 2
		s[c] = e[c] + 2
		l[c] = l[c] * 4
		e[c] = s[c] + (l[c] - 1) * 2
		pp[c] = pp[c] * 4
		c = 1 - c
	l[c] = p - pp[c] + 1
	e[c] = s[c] + (l[c] - 1) * 2
	sum += l[c] * (s[c] + e[c]) // 2
	sum = sum % md
	return sum
(l, r) = (get_sum(l - 1), get_sum(r))
ans = (r - l + md) % md
print(ans)


p = 10 ** 9 + 7
inf = 2 ** 128

def count(low, high, p):
	ret = high * (high + 1) // 2 % p
	ret = (ret - (low - 1) * low // 2) % p
	return ret

def count_even(low, high, p):
	ret = count(low, high, p) * 2 % p
	return ret

def count_odd(low, high, p):
	ret = (count(2 * low - 1, 2 * high, p) - count_even(low, high, p)) % p
	return ret

def main():
	(l, r) = list(map(int, input().strip().split()))
	start = [1, 1]
	end = [1, 2]
	length = [1, 2]
	lsum = [1, 3]
	while lsum[-1] < inf:
		start.append(end[-2] + 1)
		length.append(length[-1] * 2)
		end.append(start[-1] + length[-1] - 1)
		lsum.append(lsum[-1] + length[-1])
	(total, curr) = (0, 0)
	while lsum[curr] < l:
		curr += 1
	while lsum[curr] < r:
		low = start[curr] + l - (0 if curr == 0 else lsum[curr - 1]) - 1
		high = end[curr]
		if curr % 2 == 0:
			total = (total + count_odd(low, high, p)) % p
		else:
			total = (total + count_even(low, high, p)) % p
		l = lsum[curr] + 1
		curr += 1
	low = start[curr] + l - (0 if curr == 0 else lsum[curr - 1]) - 1
	high = end[curr] - (lsum[curr] - r)
	if curr % 2 == 0:
		total = (total + count_odd(low, high, p)) % p
	else:
		total = (total + count_even(low, high, p)) % p
	print(total)
main()


(l, r) = input().split()
(l, r) = (int(l), int(r))
(pl, pr) = (60, 60)
mod = 10 ** 9 + 7
while 2 ** pl > l:
	pl -= 1
while 2 ** pr > r:
	pr -= 1
if pr == pl:
	a = 1 if pl % 2 == 0 else 2
	for i in range(1 if pl % 2 == 0 else 2, pl, 2):
		a += 2 ** i
	ans = (r - 2 ** pl + 1) * (a + r - 2 ** pl) - (l - 2 ** pl) * (a + l - 2 ** pl - 1)
	ans %= mod
	print(ans)
else:
	al = 1 if pl % 2 == 0 else 2
	for i in range(1 if pl % 2 == 0 else 2, pl, 2):
		al += 2 ** i
	ar = 1 if pr % 2 == 0 else 2
	for i in range(1 if pr % 2 == 0 else 2, pr, 2):
		ar += 2 ** i
	n = r - 2 ** pr + 1
	ans = n * (ar + n - 1)
	ans %= mod
	n = 2 ** (pl + 1) - 2 ** pl
	ans += n * (al + n - 1)
	n = l - 2 ** pl
	ans -= n * (al + n - 1)
	ans %= mod
	it = pl + 1
	while it < pr:
		a = 1 if it % 2 == 0 else 2
		for i in range(1 if it % 2 == 0 else 2, it, 2):
			a += 2 ** i
		n = 2 ** (it + 1) - 2 ** it
		ans += n * (a + n - 1)
		ans %= mod
		it += 1
	print(ans)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

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

def Int():
	return int(input())

def Str():
	return input()

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

def fetch(x):
	cur = 0
	p = 1
	which = 1
	odd = 1
	even = 2
	tot = 0
	while cur + p <= x:
		here = p
		tot = (tot + here * (here - 1) % M) % M
		if which:
			tot = (tot + odd * here % M) % M
			odd = (odd + 2 * here % M) % M
		else:
			tot = (tot + even * here % M) % M
			even = (even + 2 * here % M) % M
		cur = cur + p
		p *= 2
		which ^= 1
	here = (x - cur + M) % M
	tot = (tot + here * (here - 1) % M) % M
	if which:
		tot = (tot + odd * here % M) % M
		odd = (odd + 2 * here % M) % M
	else:
		tot = (tot + even * here % M) % M
		even = (even + 2 * here % M) % M
	return tot
(l, r) = value()
print((fetch(r) - fetch(l - 1) + M) % M)


def even_i(q):
	if q == 2:
		return 1
	else:
		return even_i(q - 2) + 2 ** (q - 3)

def odd_i(q):
	if q == 1:
		return 1
	else:
		return odd_i(q - 2) + 2 ** (q - 3)

def q_of_j(j):
	f = 0
	while j >= 2 ** f:
		f += 1
	return f

def gen_a1(j, q):
	if q % 2 == 0:
		a_1 = 2 * even_i(q)
	if q % 2 == 1:
		a_1 = 2 * odd_i(q) - 1
	j = j - 2 ** (q - 1)
	return a_1 + 2 * j

def gen_sum(q):
	if q % 2 == 0:
		a_1 = 2 * even_i(q)
	elif q % 2 == 1:
		a_1 = 2 * odd_i(q) - 1
	return (a_1 + 2 ** (q - 1) - 1) * 2 ** (q - 1)

def gen_sum_firsthalf(j, q):
	a_1 = gen_a1(j, q)
	j = j - 2 ** (q - 1)
	r = 2 ** (q - 1) - j
	return (a_1 + r - 1) * r

def gen_sum_lasthalf(j, q):
	if q % 2 == 0:
		a_1 = 2 * even_i(q)
	elif q % 2 == 1:
		a_1 = 2 * odd_i(q) - 1
	t = j - 2 ** (q - 1) + 1
	return (a_1 + t - 1) * t

def gen_sum_samegroup(j, k, q):
	a_1 = gen_a1(j, q)
	t = k - j + 1
	return (a_1 + t - 1) * t
n = str(input())
n = n.split()
for i in range(len(n)):
	n[i] = int(n[i])
q1 = q_of_j(n[0])
q2 = q_of_j(n[1])
sum = 0
if q1 != q2:
	sum += gen_sum_firsthalf(n[0], q1)
	for i in range(q1 + 1, q2):
		sum += gen_sum(i)
	sum += gen_sum_lasthalf(n[1], q2)
else:
	sum += gen_sum_samegroup(n[0], n[1], q1)
print(sum % (10 ** 9 + 7))


arr = input()
(L, R) = [int(x) for x in arr.split(' ')]
s = 1
nums = 0
level = -1
left_level = -1
right_level = -1
cur = 0
odds = 0
evens = 0
start_odd = -1
start_even = -1
count_odd = 0
count_even = 0
while True:
	nums += s
	s *= 2
	level += 1
	if L <= nums and L >= 2 ** level:
		if level % 2 == 0:
			start_odd = odds + (L - 2 ** level + 1)
			count_odd += 2 ** (level + 1) - L
		else:
			start_even = evens + (L - 2 ** level + 1)
			count_even += 2 ** (level + 1) - L
	elif L < 2 ** level:
		if level % 2 == 0:
			if start_odd == -1:
				start_odd = odds + 1
			count_odd += 2 ** level
		else:
			if start_even == -1:
				start_even = evens + 1
			count_even += 2 ** level
	if R <= nums and R >= 2 ** level:
		if level % 2 == 0:
			count_odd -= 2 ** (level + 1) - 1 - R
		else:
			count_even -= 2 ** (level + 1) - 1 - R
	if nums >= R:
		break
	if level % 2 == 0:
		odds += 2 ** level
	else:
		evens += 2 ** level
start_odd = start_odd * 2 - 1
start_even = start_even * 2
total = 0
total += (2 * start_odd + count_odd * 2 - 2) * count_odd // 2
total += (2 * start_even + count_even * 2 - 2) * count_even // 2
print(total % 1000000007)


def get_odd(n):
	return n * n

def get_even(n):
	return n * n + n

def solve(n):
	flag = 0
	cnt = [0, 0]
	i = 1
	while n >= i:
		n -= i
		cnt[flag] += i
		flag ^= 1
		i *= 2
	cnt[flag] += n
	return get_odd(cnt[0]) + get_even(cnt[1])
(l, r) = map(int, input().split())
print((solve(r) - solve(l - 1)) % int(1000000000.0 + 7))


from sys import stdin

def get_oei(l):
	p = 1
	odd = even = 0
	is_odd = True
	for i in range(0, 61):
		if is_odd:
			odd += p
		else:
			even += p
		s = odd + even
		if s >= l:
			s = s - l
			if is_odd:
				odd -= s
			else:
				even -= s
			break
		p *= 2
		is_odd = not is_odd
	return (odd, even)

def odd_sum(l):
	return l * (1 + (1 + (l - 1) * 2)) // 2

def even_sum(l):
	return l * (2 + (2 + (l - 1) * 2)) // 2
(l, r) = [t(s) for (t, s) in zip((int, int), stdin.readline().split())]
(l_odd, l_even) = get_oei(l - 1)
l_sum = odd_sum(l_odd) + even_sum(l_even)
(r_odd, r_even) = get_oei(r)
r_sum = odd_sum(r_odd) + even_sum(r_even)
print((r_sum - l_sum) % 1000000007)


from math import ceil
from math import floor
from math import sqrt
from math import log
prime = pow(10, 9) + 7

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_sum(x):
	n = 0
	m = 0
	deg = 0
	flag = True
	while flag:
		val = pow(2, deg)
		if deg % 2 == 0:
			n += min(val, x)
		else:
			m += min(val, x)
		if x < val:
			flag = False
		else:
			x -= val
		deg += 1
	odd_sum = n % prime * (n % prime) % prime
	even_sum = m % prime * (m % prime + 1) % prime
	return (odd_sum + even_sum) % prime
t = 1
while t:
	t = t - 1
	count = 0
	(n, k) = map(int, input().split())
	arr = []
	b = []
	result = (find_sum(k) - find_sum(n - 1)) % prime
	if result < 0:
		result += prime
	print(result)


mod = 10 ** 9 + 7

def gn(n):
	return n * n % mod

def gc(n):
	return n * (n + 1) % mod

def get(n):
	num_c = 0
	num_n = 0
	now = 0
	b = 0
	while True:
		bb = 2 ** b
		if now + bb <= n:
			now += bb
			if b % 2 == 0:
				num_n += bb
			else:
				num_c += bb
		else:
			if b % 2 == 0:
				num_n += n - now
			else:
				num_c += n - now
			break
		b += 1
	return (gn(num_n) + gc(num_c)) % mod
(a, b) = map(int, input().split())
print((get(b) - get(a - 1)) % mod)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math
import heapq

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()

def find_sum(k):
	s_l1 = int(math.log2(k)) + 1
	nodes_s1 = 2 ** s_l1 - 1
	if nodes_s1 == k:
		s = 0
		for i in range(s_l1):
			s += sum_li[i]
	else:
		partial_nodes = (li[s_l1 - 1][1] - li[s_l1 - 1][0]) // 2 + 1 - (nodes_s1 - k)
		s = 0
		for i in range(s_l1 - 1):
			s += sum_li[i]
		partial_sum = partial_nodes * (2 * li[s_l1 - 1][0] + (partial_nodes - 1) * 2) // 2
		s += partial_sum
	return s
MOD = 10 ** 9 + 7
total_stages = math.ceil(math.log2(10 ** 18))
li = []
sum_li = []
odSt = 1
evSt = 2
for i in range(1, total_stages + 1):
	total_nodes = 2 ** (i - 1)
	if i % 2 != 0:
		odEnd = odSt + (total_nodes - 1) * 2
		li.append((odSt, odEnd))
		summ = total_nodes * (2 * odSt + (total_nodes - 1) * 2) // 2
		odSt = odEnd + 2
	else:
		evenEnd = evSt + (total_nodes - 1) * 2
		li.append((evSt, evenEnd))
		summ = total_nodes * (2 * evSt + (total_nodes - 1) * 2) // 2
		evSt = evenEnd + 2
	sum_li.append(summ)
(l, r) = listIn()
stage_l = int(math.log2(l)) + 1
stage_r = int(math.log2(r)) + 1
if l > 1:
	sum_l1 = find_sum(l - 1)
else:
	sum_l1 = 0
sum_r = find_sum(r)
final_sum = sum_r - sum_l1
print(final_sum % MOD)


(l, r) = map(int, input().split())
numbermean = [[1, 1], [3, 2], [6, 4]]
for i in range(30):
	numbermean.append([numbermean[i * 2 + 1][0] + 2 * (numbermean[i * 2 + 1][1] // 2 + 2 ** ((i + 1) * 2)), numbermean[i * 2 + 1][1] * 4])
	numbermean.append([numbermean[i * 2 + 2][0] + 2 * (numbermean[i * 2 + 2][1] // 2 + 2 ** ((i + 1) * 2 + 1)), numbermean[i * 2 + 2][1] * 4])
numbermean
l -= 1
lsum = 0
for i in range(62):
	if l - numbermean[i][1] >= 0:
		l -= numbermean[i][1]
		lsum += numbermean[i][0] * numbermean[i][1]
	else:
		next = i
		break
begin = numbermean[next][0] - numbermean[next][1] + 1
lsum += l * (begin + (l - 1))
rsum = 0
for i in range(62):
	if r - numbermean[i][1] >= 0:
		r -= numbermean[i][1]
		rsum += numbermean[i][0] * numbermean[i][1]
	else:
		next = i
		break
begin = numbermean[next][0] - numbermean[next][1] + 1
rsum += r * (begin + (r - 1))
print((rsum - lsum) % 1000000007)


MOD = 1000000007

def groups_before(n):
	result = 0
	x = 1
	while x * 2 <= n:
		result += 1
		x *= 2
	return result

def arithmetic(a, d, n):
	return (2 * a + d * (n - 1)) // 2 * n

def geometric(b, q, n):
	return b * (1 - q ** n) // (1 - q)

def sum_up(n):
	g = groups_before(n)
	g_odd = g // 2 + (1 if g % 2 == 1 else 0)
	g_even = g // 2
	reminder = n - (2 ** g - 1)
	n_odd = geometric(1, 4, g_odd)
	n_even = geometric(2, 4, g_even)
	if g % 2 == 0:
		n_odd += reminder
	else:
		n_even += reminder
	return arithmetic(1, 2, n_odd) + arithmetic(2, 2, n_even)

def main():
	(l, r) = map(int, input().split())
	print((sum_up(r) - sum_up(l - 1)) % MOD)
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]
MOD = 10 ** 9 + 7

def sum_evens(l, r):
	return pow(r, 2, MOD) - pow(l, 2, MOD) + r + l

def sum_odds(l, r):
	return pow(r, 2, MOD) - pow(l, 2, MOD) + 2 * l - 1

def solve():
	(L, R) = getInts()
	odd_blocks = [(1, 1)]
	even_blocks = [(1, 2)]
	for i in range(30):
		(os, oe) = odd_blocks[-1]
		(es, ee) = even_blocks[-1]
		ol = oe - os + 1
		el = ee - es + 1
		odd_blocks.append((oe + 1, oe + ol * 4))
		even_blocks.append((ee + 1, ee + el * 4))
	blocks = []
	for i in range(62):
		if i % 2 == 0:
			blocks.append(even_blocks.pop())
		else:
			blocks.append(odd_blocks.pop())
	blocks.reverse()
	start_block = len(bin(L)) - 3
	start_pos = L - pow(2, len(bin(L)) - 3)
	end_block = len(bin(R)) - 3
	end_pos = R - pow(2, len(bin(R)) - 3)
	ans = 0
	for block in range(start_block + 1, end_block):
		if block % 2 == 0:
			ans += sum_odds(blocks[block][0], blocks[block][1])
		else:
			ans += sum_evens(blocks[block][0], blocks[block][1])
		ans %= MOD
	if start_block % 2 == 0:
		ans += sum_odds(blocks[start_block][0] + start_pos, blocks[start_block][1])
	else:
		ans += sum_evens(blocks[start_block][0] + start_pos, blocks[start_block][1])
	ans %= MOD
	if end_block % 2 == 0:
		ans += sum_odds(blocks[end_block][0], blocks[end_block][0] + end_pos)
	else:
		ans += sum_evens(blocks[end_block][0], blocks[end_block][0] + end_pos)
	ans %= MOD
	if start_block == end_block:
		if start_block % 2 == 0:
			ans -= sum_odds(blocks[start_block][0], blocks[start_block][1])
		else:
			ans -= sum_evens(blocks[start_block][0], blocks[start_block][1])
	ans %= MOD
	return ans
print(solve())


def f(R):
	if R == 0:
		return 0
	F = 0
	S = 0
	cur = 1
	for i in range(150):
		t = min(cur, R - F - S)
		if i % 2 == 0:
			F = F + t
		else:
			S = S + t
		cur = cur * 2
		if R == F + S:
			break
	ans = F * F + S * S + S
	return ans
(L, R) = map(int, input().strip().split())
L = L - 1
ans = f(R) - f(L)
ans = ans % 1000000007
print(ans)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True

def find(lb):
	l = len(lb)
	b = ['', '', '']
	for i in range(l + 1):
		x = str((i + 1) % 2)
		if i < l - 1:
			b[0] += x
		if i < l:
			b[1] += x
		b[2] += x
	if lb == '0':
		b[0] = '0'
	return b[1:] if lb >= b[1] else b[:2]

def solve(n):
	bn = bin(n)[2:]
	(x, y) = find(bn)
	x = int(x, 2)
	y = int(y, 2)
	ml = [x - 1, x, y - 1, y]
	if n in ml:
		n %= mod
		return n * (n + 1) // 2
	mn = min(n - ml[1], ml[2] - n)
	mn %= mod
	n %= mod
	return n * (n + 1) // 2 + mn * (mn + 1) // 2
(l, r) = mp()
sr = solve(r)
sl = solve(l - 1)
print((sr % mod + mod - sl % mod) % mod)


MOD = 10 ** 9 + 7
(L, R) = map(int, input().split())
(a, b, q, odd) = (1, 2, 1, True)
s = 0
number = 0
while number < R:
	sub = max([0, min([L - number - 1, q])])
	seg = min([max([0, R - number]), q])
	if odd:
		s = (s + a * seg + seg * (seg - 1) - a * sub - sub * (sub - 1)) % MOD
		a += 2 * q
	else:
		s = (s + b * seg + seg * (seg - 1) - b * sub - sub * (sub - 1)) % MOD
		b += 2 * q
	number += q
	q *= 2
	odd = not odd
print(s)


p = int(1000000000.0 + 7)
rec = [[int(0), int(0), int(0)]]
rng = 1
for i in range(64):
	rec.append([rec[i][0], rec[i][1], rec[i][2]])
	if i % 2 == 0:
		rec[i + 1][0] += rng
		rec[i + 1][2] += (rec[i][0] * 2 + 1 + (rec[i + 1][0] * 2 - 1)) * rng // 2 % p
	else:
		rec[i + 1][1] += rng
		rec[i + 1][2] += (rec[i][1] * 2 + 2 + rec[i + 1][1] * 2) * rng // 2 % p
	rng *= 2

def calc(n):
	ret = 0
	for i in range(65):
		if rec[i][0] + rec[i][1] > n:
			ret = rec[i - 1][2]
			rem = n - (rec[i - 1][0] + rec[i - 1][1])
			if rem > 0:
				if i % 2 == 1:
					ret += (rec[i - 1][0] * 2 + 1 + ((rec[i - 1][0] + rem) * 2 - 1)) * rem // 2 % p
				else:
					ret += (rec[i - 1][1] * 2 + 2 + (rec[i - 1][1] + rem) * 2) * rem // 2 % p
			return ret
(l, r) = map(int, input().split())
print(round((calc(r) - calc(l - 1) + p) % p))


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():

	def rngsum(x, l):
		ans = 2 * x + l
		ans *= x
		ans //= 2
		return ans

	def get(x):
		(odd, even) = (0, 0)
		for i in range(62):
			c = (1 << i + 1) - 1
			extra = 0
			if c >= x:
				extra = c - x
			if i % 2 == 0:
				odd += 1 << i
				odd -= extra
			else:
				even += 1 << i
				even -= extra
			if c >= x:
				break
		return (rngsum(odd, 0) + rngsum(even, 2)) % mod
	(l, r) = mi()
	ans = get(r)
	ans -= get(l - 1)
	ans += mod
	ans %= mod
	print(ans)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


(n, m) = map(int, input().split())
mod = 1000000007
S = []
P = []

def getsum(x):
	if x == 0:
		return 0
	if x == 1:
		return 1
	i = 1
	nr = 0
	while i <= x:
		i = i * 2
		nr = nr + 1
	i = i // 4
	nr = nr - 1
	tot = S[nr - 1]
	lng = x - (i * 2 - 1)
	up = P[nr] + 2 * (lng - 1)
	lp = P[nr] - 2
	if P[nr] % 2 == 0:
		x = up // 2
		y = lp // 2
		tot = tot + 2 * (x * (x + 1) // 2) - 2 * (y * (y + 1) // 2)
	else:
		tot = tot + ((up + 1) // 2) ** 2 - ((lp + 1) // 2) ** 2
	return tot % mod
lp = 0
li = -1
lng = 1
for i in range(0, 80):
	if i % 2 == 0:
		ui = li + 2 + (lng - 1) * 2
		if i == 0:
			S.append(1)
			P.append(1)
		else:
			S.append((S[i - 1] + ((ui + 1) // 2) ** 2 - ((li + 1) // 2) ** 2) % mod)
			P.append(li + 2)
		li = ui
	else:
		up = lp + 2 + (lng - 1) * 2
		if i == 1:
			S.append(7)
			P.append(2)
		else:
			x = up // 2
			y = lp // 2
			S.append((S[i - 1] + 2 * (x * (x + 1) // 2) - 2 * (y * (y + 1) // 2)) % mod)
			P.append(lp + 2)
		lp = up
	lng = lng * 2
ans = (getsum(m) - getsum(n - 1)) % mod
if ans < 0:
	ans = ans + mod
print(ans)


import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7

def calc(x):
	turn = 0
	odd = 0
	even = 0
	k = 1
	s = 0
	while s + k < x:
		s += k
		k *= 2
		if turn % 2 == 0:
			odd += 1
		else:
			even += 1
		turn ^= 1
	r = x - s
	cnt1 = 0
	v1 = 1
	for i in range(odd):
		cnt1 += v1
		v1 *= 4
	cnt2 = 0
	v2 = 2
	for i in range(even):
		cnt2 += v2
		v2 *= 4
	if turn == 1:
		cnt2 += r
	else:
		cnt1 += r
	ans = (cnt1 ** 2 + cnt2 * (cnt2 + 1)) % mod
	return ans
(l, r) = map(int, input().split())
print((calc(r) - calc(l - 1)) % mod)


def cnts(n):
	t = 1
	set_num = 1
	cnt = [0, 0]
	while t < n:
		cnt[set_num] += t
		n -= t
		t <<= 1
		set_num ^= 1
	cnt[set_num] += n
	return cnt

def f(n):
	(l, r) = cnts(n)
	return l * (l + 1) + r * r
(l, r) = map(int, input().split())
print((f(r) - f(l - 1)) % int(1000000000.0 + 7))


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
from heapq import heapify, heappush, heappop, heappushpop
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
(a, b) = R()
x = 0
y = 0
c = 0
ans = 0
i = 0
while c < b:
	if not i & 1:
		if c + (1 << i) >= a:
			ans = (ans + pow((1 << i) + x - max(0, c + (1 << i) - b), 2, N) - pow(x + max(0, a - c - 1), 2, N)) % N
		x += 1 << i
	else:
		p = (1 << i) + y - max(0, c + (1 << i) - b)
		q = y + max(0, a - c - 1)
		if c + (1 << i) >= a:
			ans = (ans + (p ** 2 + p) % N - (q ** 2 + q) % N) % N
		y += 1 << i
	c += 1 << i
	i += 1
print(ans)


MOD = int(1000000000.0 + 7)

def binpow(a, n):
	res = 1
	while n:
		if n % 2:
			res *= a
			res %= MOD
		a *= a
		a %= MOD
		n //= 2
	return res
(l, r) = map(int, input().split())
l -= 1
cur = 0
sum1 = 0
nc = 2
nn = 1
pw = [1 for i in range(62)]
for i in range(1, 62):
	pw[i] = pw[i - 1] * 2
for i in range(61):
	if cur <= l and cur + pw[i] > l:
		left = l - cur
		if i % 2:
			sum1 += (2 * nc + (left - 1) * 2) % MOD * left % MOD * binpow(2, MOD - 2)
			sum1 %= MOD
		else:
			sum1 += (2 * nn + (left - 1) * 2) % MOD * left % MOD * binpow(2, MOD - 2)
			sum1 %= MOD
		break
	else:
		wc = nc
		wn = nn
		if i % 2:
			nc += pw[i + 1]
			sum1 += (wc + nc - 2) * pw[i] % MOD * binpow(2, MOD - 2)
			sum1 %= MOD
		else:
			nn += pw[i + 1]
			sum1 += (wn + nn - 2) * pw[i] % MOD * binpow(2, MOD - 2)
			sum1 %= MOD
		cur += pw[i]
		mx = i
curr = 0
mxr = 0
sum2 = 0
nc = 2
nn = 1
for i in range(61):
	if curr <= r and curr + pw[i] > r:
		left = r - curr
		if i % 2:
			sum2 += (2 * nc + (left - 1) * 2) % MOD * left % MOD * binpow(2, MOD - 2)
			sum2 %= MOD
		else:
			sum2 += (2 * nn + (left - 1) * 2) % MOD * left % MOD * binpow(2, MOD - 2)
			sum2 %= MOD
		break
	else:
		wc = nc
		wn = nn
		if i % 2:
			nc += pw[i + 1]
			sum2 += (wc + nc - 2) * pw[i] % MOD * binpow(2, MOD - 2)
			sum2 %= MOD
		else:
			nn += pw[i + 1]
			sum2 += (wn + nn - 2) * pw[i] % MOD * binpow(2, MOD - 2)
			sum2 %= MOD
		curr += pw[i]
		mx = i
print((sum2 - sum1 + MOD) % MOD)


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

def oddSum(n):
	return n * n

def func(sett, count_odd, count_even, l, num, nextsum):
	if num == 0:
		num = 1
	else:
		num = num * 2
	nextsum = nextsum + num
	if nextsum > l:
		return (sett, count_odd, count_even, num)
	if sett == 1:
		count_odd += num
		sett = 2
	else:
		count_even += num
		sett = 1
	return func(sett, count_odd, count_even, l, num, nextsum)
(l, r) = input().split()
l = int(l)
l -= 1
r = int(r)
count_odd = 0
count_even = 0
count_odd2 = 0
count_even2 = 0
x = func(1, count_odd, count_even, l, 0, 0)
y = func(1, count_odd2, count_even2, r, 0, 0)
if x[0] == 1:
	count_odd = x[1]
	count_odd += l - x[1] - x[2]
	count_even = x[2]
else:
	count_even = x[2]
	count_even += l - x[1] - x[2]
	count_odd = x[1]
if y[0] == 1:
	count_odd2 = y[1]
	count_odd2 += r - y[1] - y[2]
	count_even2 = y[2]
else:
	count_even2 = y[2]
	count_even2 += r - y[1] - y[2]
	count_odd2 = y[1]
s = 0
s += evensum(count_even2)
s -= evensum(count_even)
s += oddSum(count_odd2)
s -= oddSum(count_odd)
print(s % 1000000007)


mod = 1000000007

def f(n):
	if n == 0:
		return 0
	w = 1
	for i in range(1, 64):
		if n + 1 >= 1 << i:
			w = i
		else:
			break
	ji = w // 2
	o = w // 2
	if w & 1:
		ji += 1
	ans = 0
	jinum = 0
	onum = 0
	temp = 1
	for i in range(ji):
		jinum += temp
		temp <<= 2
	temp = 2
	for i in range(o):
		onum += temp
		temp <<= 2
	ans += (1 + jinum * 2 - 1) * jinum // 2
	ans += (2 + onum * 2) * onum // 2
	if w & 1:
		ans += (onum * 2 + onum * 2 + 2 + (n - jinum - onum) * 2) * (n - jinum - onum) // 2
	else:
		ans += (jinum * 2 + 1 + jinum * 2 - 1 + 2 * (n - jinum - onum)) * (n - jinum - onum) // 2
	return ans
(l, r) = map(int, input().split())
print((f(r) - f(l - 1)) % mod)


(l, r) = map(int, input().split())
MOD = 1000 * 1000 * 1000 + 7

def getSum(first, n):
	return (first + n - 1) * n % MOD

def f(pos):
	curNum = [0, 0]
	curNum[1] = 3
	curNum[0] = 2
	cur = 0
	cpos = 1
	sum = 1
	p2 = 2
	while cpos + p2 <= pos:
		cpos += p2
		sum += getSum(curNum[cur], p2)
		sum %= MOD
		curNum[cur] += p2 * 2
		cur = 1 - cur
		p2 *= 2
	sum += getSum(curNum[cur], pos - cpos)
	sum %= MOD
	return sum
sum = f(r)
if l - 1 >= 1:
	sum = sum + MOD - f(l - 1)
sum += MOD
print(sum % MOD)


def li():
	return set(map(int, input().split(' ')))

def sm(l, r):
	return (l + r) * ((r - l + 2) // 2) // 2

def do(n):
	if n <= 0:
		return 0
	l = r = 0
	pw = c = 1
	while n >= pw:
		if c:
			l += pw
		else:
			r += pw
		n -= pw
		pw *= 2
		c = 1 - c
	if n > 0:
		if c:
			l += n
		else:
			r += n
	return sm(2, 2 * r) + sm(1, 2 * l - 1)
(a, b) = input().split(' ')
a = int(a)
b = int(b)
print((do(b) - do(a - 1)) % 1000000007)


def solve(n):
	cur = 0
	two = 1
	eq = 1
	while cur + two <= n:
		cur += two
		two *= 2
		eq ^= 1
	if eq == 1:
		toteven = cur // 3 * 2
		totodd = cur // 3
		totodd += n - cur
	else:
		toteven = (cur - 1) // 3
		totodd = 2 * (cur - 1) // 3 + 1
		toteven += n - cur
	return toteven * (toteven + 1) + totodd * totodd
(l, r) = map(int, input().split())
a = solve(r)
b = solve(l - 1)
print((a - b) % (10 ** 9 + 7))


mod = pow(10, 9) + 7

def solve(a):
	count = 0
	odd = 0
	even = 0
	cur = 1
	suma = 0
	while a > 0:
		maxa = min(cur, a)
		if count == 0:
			odd += maxa
		else:
			even += maxa
		count = count ^ 1
		a = a - maxa
		cur = cur * 2
	suma = (suma + odd * odd % mod) % mod
	suma = (suma + (even * even + even) % mod) % mod
	return suma
(l, r) = list(map(int, input().split()))
ans = solve(r) - solve(l - 1)
ans = (ans + mod) % mod
print(ans)


MOD = 1000000007

def rangeSum(a, b):
	if a & 1 == 1:
		a = (a + 1) // 2 - 1
		b = (b + 1) // 2
		return (b * b % MOD - a * a % MOD) % MOD
	a = a // 2 - 1
	b //= 2
	return (b * (b + 1) % MOD - a * (a + 1) % MOD) % MOD
(left, right) = map(int, input().split())
sections = [-1, (1, 1), (2, 4)]
for i in range(3, 64):
	(prevStart, prevEnd) = sections[i - 2]
	if i & 1 == 1:
		start = prevStart * 4 - 1
		end = start * 4 - 3
	else:
		start = prevStart * 4 - 2
		end = start * 4 - 4
	sections.append((start, end))
sectionLeft = sectionRight = None
count = 1
for i in range(1, 64):
	if sectionLeft and sectionRight:
		break
	if not sectionLeft and count >= left:
		sectionLeft = i
	if not sectionRight and count >= right:
		sectionRight = i
	count = count + (1 << i)
ret = 0
for i in range(sectionLeft + 1, sectionRight):
	ret = (ret + rangeSum(*sections[i])) % MOD
leftSectionFirstNum = sections[sectionLeft][0]
leftSectionLastNum = sections[sectionLeft][1]
startIndex = 1 << sectionLeft - 1
leftNum = (left - startIndex) * 2 + leftSectionFirstNum
rightSectionFirstNum = sections[sectionRight][0]
endIndex = 1 << sectionRight - 1
rightNum = (right - endIndex) * 2 + rightSectionFirstNum
if sectionLeft == sectionRight:
	ret = (ret + rangeSum(leftNum, rightNum)) % MOD
else:
	ret = (ret + rangeSum(leftNum, leftSectionLastNum)) % MOD
	ret = (ret + rangeSum(rightSectionFirstNum, rightNum)) % MOD
print(ret)


import sys
input = sys.stdin.readline
M = 1000000007

def sm(n):
	(total, odd, even) = (0, 1, 2)
	atodd = True
	k = 1
	while n:
		k = min(k, n)
		n -= k
		if atodd:
			atodd = False
			total += k * (odd + odd + (k - 1) * 2) // 2
			total %= M
			odd += k * 2
		else:
			atodd = True
			total += k * (even + even + (k - 1) * 2) // 2
			total %= M
			even += k * 2
		k *= 2
	return total
(l, r) = map(int, input().split())
print((sm(r) - sm(l - 1)) % M)


def func(x):
	a = 1
	b = 0
	while 1 > 0:
		if a < x:
			b = b + 1
			a = a + 2 ** b
		else:
			a = a - 2 ** b
			b = b - 1
			break
	c = 0
	d = 0
	for i in range(b + 1):
		if i % 2 == 0:
			c = c + 2 ** i
		else:
			d = d + 2 ** i
	if b % 2 != 0:
		c = c + (x - a)
	else:
		d = d + (x - a)
	return c ** 2 + d * (d + 1)
(l, r) = list(map(int, input().split()))
a = 1000000007
print((func(r) - func(l - 1)) % a)


a = [1, 2, 3, 6, 11, 22, 43, 86, 171, 342, 683, 1366, 2731, 5462, 10923, 21846, 43691, 87382, 174763, 349526, 699051, 1398102, 2796203, 5592406, 11184811, 22369622, 44739243, 89478486, 178956971, 357913942, 715827883, 1431655766, 2863311531, 5726623062, 11453246123, 22906492246, 45812984491, 91625968982, 183251937963, 366503875926, 733007751851, 1466015503702, 2932031007403, 5864062014806, 11728124029611, 23456248059222, 46912496118443, 93824992236886, 187649984473771, 375299968947542, 750599937895083, 1501199875790166, 3002399751580331, 6004799503160662, 12009599006321323, 24019198012642646, 48038396025285291, 96076792050570582, 192153584101141163, 384307168202282326, 768614336404564651, 1537228672809129302, 3074457345618258603, 6148914691236517206]
b = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808, 18446744073709551616, 36893488147419103232, 73786976294838206464, 147573952589676412928, 295147905179352825856, 590295810358705651712, 1180591620717411303424, 2361183241434822606848, 4722366482869645213696, 9444732965739290427392, 18889465931478580854784, 37778931862957161709568, 75557863725914323419136, 151115727451828646838272, 302231454903657293676544, 604462909807314587353088, 1208925819614629174706176, 2417851639229258349412352, 4835703278458516698824704, 9671406556917033397649408, 19342813113834066795298816, 38685626227668133590597632, 77371252455336267181195264, 154742504910672534362390528, 309485009821345068724781056, 618970019642690137449562112, 1237940039285380274899124224, 2475880078570760549798248448, 4951760157141521099596496896, 9903520314283042199192993792, 19807040628566084398385987584, 39614081257132168796771975168, 79228162514264337593543950336, 158456325028528675187087900672, 316912650057057350374175801344, 633825300114114700748351602688]
(n, m) = map(int, input().split())
t = 100
t1 = 0
while 2 ** t > n:
	t -= 1
while 2 ** t1 <= m:
	t1 += 1
ans = 0
for i in range(t, t1):
	if i != t1 - 1 and i != t:
		ans += (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
	elif i == t == t1 - 1:
		if m == b[i + 1] - 1 and n == b[i]:
			ans += (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
		elif m != b[i + 1] - 1 and n == b[i]:
			x1 = (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
			x2 = a[i] + 2 * (m - b[i] + 1)
			x3 = a[i] + sum(b[:i + 1]) - 1
			ans += x1 - (x2 + x3) // 2 * ((x3 - x2) // 2 + 1)
		elif m == b[i + 1] - 1 and n != b[i]:
			x1 = (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
			x7 = n - b[i]
			x2 = (a[i] + a[i] + 2 * (n - b[i] - 1)) // 2 * x7
			ans += x1 - x2
		else:
			x1 = a[i] + 2 * (n - b[i])
			x2 = a[i] + 2 * (m - b[i])
			ans += (x1 + x2) // 2 * ((x2 - x1) // 2 + 1)
	elif i == t:
		if n != b[i]:
			x1 = (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
			x7 = n - b[i]
			x2 = (a[i] + a[i] + 2 * (n - b[i] - 1)) // 2 * x7
			ans += x1 - x2
		else:
			ans += (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
	elif m != b[i + 1] - 1:
		x1 = (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
		x2 = a[i] + 2 * (m - b[i] + 1)
		x3 = a[i] + sum(b[:i + 1]) - 1
		ans += x1 - (x2 + x3) // 2 * ((x3 - x2) // 2 + 1)
	else:
		ans += (2 * a[i] + sum(b[:i + 1]) - 1) // 2 * b[i]
print(ans % 1000000007)


MOD = 1000000007

def sum_pos(pos):
	group = 1
	ki = kp = 0
	p2 = 1
	numbers = 0
	while numbers < pos:
		if numbers + p2 > pos or numbers + p2 < 0:
			p2 = pos - numbers
		numbers += p2
		if group == 1:
			ki += p2
		else:
			kp += p2
		group = 3 - group
		p2 *= 2
	ans = kp % MOD * ((kp + 1) % MOD) % MOD
	ans = ans + ki % MOD * (ki % MOD) % MOD
	ans %= MOD
	return ans
line = list(map(int, input().split()))
left = line[0]
right = line[1]
ans = sum_pos(right) - sum_pos(left - 1)
while ans < 0:
	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)


mod = pow(10, 9) + 7

def calc(num):
	res = 0
	ab = [1, 2]
	index = 0
	cnt = 0
	p = 1
	while True:
		if cnt + p >= num:
			n = (num - cnt) % mod
			res += ab[index] * n + n * (n - 1)
			res %= mod
			break
		n = p % mod
		cnt += p
		res += ab[index] * n + n * (n - 1)
		res %= mod
		ab[index] += p * 2
		p *= 2
		index = (index + 1) % 2
	return res
(L, R) = map(int, input().split())
ans = (calc(R) % mod - calc(L - 1) % mod) % mod
if ans < 0:
	ans += mod
print(ans)


m = 1000000007

def l(n):
	o = 0
	e = 0
	tot = 0
	state = 0
	i = 1
	while i:
		tot = tot + i
		if tot >= n:
			tot = tot - i
			break
		if state == 0:
			o = o + i
		else:
			e = e + i
		i = i * 2
		state = 1 - state
	if state == 0:
		o = o + n - tot
	else:
		e = e + n - tot
	ret = e % m * ((e + 1) % m)
	ret = (ret + o % m * ((o + 1) % m) - o + m) % m
	return ret
(ll, rr) = [int(i) for i in input().split()]
print((l(rr) - l(ll - 1) + m) % m)


MOD = int(1000000000.0 + 7)

def pre(upto):
	pow2 = 1
	a = 1
	x = 1
	y = 2
	r = 1
	while True:
		if a + pow2 - 1 >= upto:
			if r % 2 == 1:
				x = x + 2 * (upto - a)
				y -= 2
			else:
				y = y + 2 * (upto - a)
				x -= 2
			return (x // 2 + 1) * (x // 2 + 1) + (y // 2 + 1) * (y // 2)
		if r % 2 == 1:
			x += pow2 * 2
		else:
			y += pow2 * 2
		a += pow2
		pow2 *= 2
		r += 1
(l, r) = map(int, input().split())
sub = -1
if l == 1:
	sub = 0
else:
	sub = pre(l - 1)
val = (pre(r) - sub) % MOD
print(val)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	(l, r) = map(int, input().split())
	(s, t) = (1, 1)
	(i, j) = (0, 0)
	while l > s:
		l = l - s
		s = s * 2
		i += 1
	while r > t:
		r = r - t
		t = t * 2
		j += 1
	res = [1, 2]
	mod = 10 ** 9 + 7
	for k in range(1, j + 1):
		if k % 2 == 0:
			res.append(res[k - 2] + 2 ** (k - 1))
		elif k > 1:
			res.append(res[k - 2] + 2 ** (k - 1))
	if i == j:
		ans = (res[i] + (l - 1) * 2 + (res[j] + (r - 1) * 2)) * (r - l + 1) // 2
		print(ans % mod)
		return
	ans = (res[i] + (l - 1) * 2 + (res[i] + (2 ** i - 1) * 2)) * (2 ** i - l + 1) // 2
	ans += (res[j] + (res[j] + (r - 1) * 2)) * r // 2
	for k in range(i + 1, j):
		ans += (res[k] + res[k] + (2 ** k - 1) * 2) * 2 ** k // 2
	print(ans % mod)
main()


mod = 1000000007

def get(loc):
	st = [1, 2]
	Sum = 0
	numele = 1
	i = 0
	while loc:
		loc -= numele
		endele = st[i] + 2 * numele - 2
		Sum += (st[i] + endele) // 2 % mod * numele % mod
		st[i] = endele + 2
		numele = min(2 * numele, loc)
		i ^= 1
	return Sum
(l, r) = map(int, input().split())
ans = (mod + get(r) - get(l - 1)) % mod
print(ans)


mod = int(1000000000.0 + 7)

def solve(x):
	if x <= 0:
		return 0
	flag = 1
	t = 1
	sum1 = 0
	sum2 = 0
	i = 0
	while i < x:
		nxt = min(i + t, x)
		if flag:
			sum1 += nxt - i
		else:
			sum2 += nxt - i
		t *= 2
		i = nxt
		flag ^= 1
	ans = sum2 % mod * ((sum2 + 1) % mod) % mod + sum1 % mod * (sum1 % mod) % mod
	return ans % mod

def main():
	(l, r) = list(map(int, input().split(' ')))
	print((solve(r) - solve(l - 1) + mod) % mod)
main()