An integer is said to be prime palindrome if it is a prime number and its reverse is same as that of the original number.
 Your task is to output the sum of all such prime palindromes lies between the range N and M (N and M both are inclusive).


Input description.

The first line of input contains an integer Tdenoting the number of test cases.
The Second line contains two integers N and M denoting the range.



Output Description:

Output is the sum of all prime palindromes lies between N and M.

 

Constraints

1 ≤ T ≤ 100
1 ≤ N ≤ M≤10^8

 

Example
Input:
1
1 101

Output:
129

 

Explanation
TestCase 1]: The prime palindromes lies between the range 1 to 101 are 2,3,5,7,11 and 101.The sum of all these numbers is 129 which is the
				output.
a = input()

def prime(number):
    flag = 1
    if number == 2:
        return True
    else:
        for a in range(2,number):
            if number % a == 0:
                flag = 1
                break
            else:
                flag = 0
        if flag == 0:
            return True
        else:
            return False
def palindrome(number):
    l1 = list(str(number))
    if l1 == l1[::-1]:
        return True
    else:
        return False

for b in range(a):
    total = 0
    c = raw_input().split()
    for b in range(int(c[0]),int(c[1])+1):
        if prime(b) == True and palindrome(b) == True:
            total += b
    print total