The XOR pair representation (XPR) of a positive integer $N$ is defined as a pair of integers $(A, B)$ such that:
- $1 \le A \le B \le N$
- $A \oplus B = N$
- if there is no way to choose $A$ and $B$ satisfying the above conditions, $A = B = -1$
- otherwise, the value of $A$ should be the smallest possible
These conditions uniquely define the XPR. Next, we define a function $F(N)$ = the value of $B$ in $XPR(N)$, and a function $G(L, R) = \sum\limits_{i=L}^R F(i)$.
You are given $L$ and $R$. Compute $G(L, R)$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains two space-separated integers $L$ and $R$.

-----Output-----
For each test case, print a single line containing one integer — the value of the function $G(L, R)$.

-----Constraints-----
- $1 \le T \le 10^5$
- $1 \le L \le R \le 10^9$

-----Example Input-----
5
1 10
3 6
4 10
10 17
100 159

-----Example Output-----
28
9
28
79
7485

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import math \nfrom collections import defaultdict\ndef IsPowerOfTwo(x):\n return (x != 0) and ((x & (x - 1)) == 0)\n\ndef getFirstSetBitPos(n): \n  return int(math.log2(n&-n)+1)-1\n\ndef xpr(n):\n if IsPowerOfTwo(n): \n  return (-1, -1)\n # Has the first set bit from lsb\n index = getFirstSetBitPos(n)\n # print("Index : ", index)\n # Convert the number to binary string\n binary_n_string = str(bin(n))[2:]\n # print(binary_n_string)\n a = ""\n b = ""\n i = 0\n for bit in reversed(binary_n_string):\n  if i < index:\n   a = \'0\' + a\n   b = \'0\' + b\n  elif i == index:\n   a = \'1\' + a\n   b = \'0\' + b\n  else:\n   if bit == \'0\':\n    a = \'0\' + a\n    b = \'0\' + b\n   else:\n    a = \'0\' + a\n    b = \'1\' + b\n  i = i + 1\n a, b = int(a, 2), int(b, 2)\n return (a, b)\n \n \ndef glr(x):\n tot = (x*(x+1))//2\n lb = 0\n while x >= 1:\n  tot -= int(((x+1)//2)*2**lb)\n  lb += 1\n  tot -= 1\n  x = x / 2\n return tot \n \nt = int(input())\nwhile t > 0:\n l, r = list(map(int,input().split()))\n sumt = 0\n # dict1 = defaultdict(int)\n # for i in range(l, r+1):\n #   val = xpr(i)\n #   if val[1] != -1 and i%2 == 0:\n #       dict1[val[1]] += 1\n #   # print(i, val)\n #   sumt += val[1]\n \n print(glr(r) - glr(l-1))\n t = t - 1'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14167