The Palindromes

A string is said to be palindrome, if it reads same from both ends, i.e, from left-to-right and from

right-to-left. For example, “MALAYALAM” is a palindrome string. The letters are symmetrical at

both ends.

Similarly, a numeral palindrome has corresponding digits from the both ends symmetrical. So, on

reversing the digits of the number, we get the same number itself. Thus, 23432 is a palindrome

number. Further, some numbers have the property that they are palindrome in both decimal, and

binary bases. One such example is the number 58510 = 10010010012

We see that both 585 and 1001001001 are palindromes.

Task

In a given range, you have to find out those numbers which are palindrome in both decimal and

binary bases, and report their decimal sum.

Input

The first line of the input will have a single integer t (1 <= t <= 50), the number of test cases. Then,

t test cases will follow. Each test case will consist of two numbers m and n, which will define the

lower limit and the upper limit of the range (m, n <= 10000000 and m < n).

Output

The output will contain t lines with exactly one number on each line, the sum of all the palindromes

(in both decimal and binary bases) that lie in the given range [m, n].