Fun with palindrome

4.1

17 votes
Very-Easy
Problem

In class student were making noise in proxy period so in order to keep the student busy sir asked Nitin the meaning of palindrome and he answered with an example my Name so sir assigned him an interesting task of finding the palindromic. A number is called palindromic if its decimal representation is a palindrome. You are given a range, described by a pair of integers L and R. Find the sum of all palindromic numbers lying in the range [L, R], inclusive of both the extrema.

Input

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of each test case contains a pair of space separated integers L and R denoting the range for which you are required to find the sum of the palindromic numbers.

Output

For each test case, output a single line containing the sum of all the palindromic numbers in the given range.

Constraints

1 ≤ T ≤ 100 1 ≤ L ≤ R ≤ 10^5

Example Input: 3 1 10 338 1500 221 442

Output: 45 50403 7212

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Example case 1. The palindromic numbers between 1 and 10 are all numbers except the number 10. Their sum is 45.

Example case 2. The palindromic numbers between 338 and 1500 and their sum is 50403 and similarly in example case 3 the sum is 7212.

Editor Image

?