Rahul is a maths genius so he came up with a game and as raj is Rahul's best friend so Rahul decided to play the game with raj. Rahul gives raj two numbers LL and RR and asks raj to find the count of numbers in the range from LL to RR (LL and RR inclusive) which are a digit palindromic. A number is a digit palindromic if its first digit is the same as its last digit. As raj is not very good at maths so your task is to help Raj find out how many numbers are a digit palindromic in the range LL to RR. For example if LL = 88 and RR = 2525 .The following numbers are a digit palindromic in the range of LL to RR: 8, 9, 11, and 22. If LL = 12511251 and RR = 12661266. The digit palindromic numbers are 1251 and 1261.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

i want code in python

 

Rahul is a maths genius so he came up with a game and as raj is Rahul's best friend so Rahul decided to play the game with raj. Rahul gives raj two numbers LL and RR and asks raj to find the count of numbers in the range from LL to RR (LL and RR inclusive) which are a digit palindromic. A number is a digit palindromic if its first digit is the same as its last digit.

As raj is not very good at maths so your task is to help Raj find out how many numbers are a digit palindromic in the range LL to RR.

For example if LL = 88 and RR = 2525 .The following numbers are a digit palindromic in the range of LL to RR: 8, 9, 11, and 22.

If LL = 12511251 and RR = 12661266. The digit palindromic numbers are 1251 and 1261.

Input format

The first line contains an integer denoting the number of test cases.

Each test case is described by a single line that contains two integers LL and RR.

Output format

For each test case output, an integer denoting how many a digit palindromic numbers are there in the given range.

Constraints

1≤T≤5∗1041≤T≤5∗104 1≤l≤r≤10181≤l≤r≤1018.

Time Limit

1 second

Example

Input

3 8 25 1251 1266 12 21

Output

4 2 0

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning