MYQ10 - Mirror Number

no tags 

A number is called a mirror number if on lateral inversion, it gives the same number i.e. it looks the same in a mirror. For example 101 is a mirror number while 100 is not. 

Given two numbers a and b, find the number of mirror numbers in between them (inclusive of a and b).

Input

First line contains T, number of test cases <= 10^5.
Each test case is described in a single line containing two numbers a and b.

0 <= a <= b <= 10^44

Output

For each test case print the number of mirror numbers between a and b in a single line.

Example

Input:
3
0 10
10 20
1 4 Output: 3
1
1

hide comments
darryl: 2013-09-20 14:16:42

I learned that checking for 0 to 10^44 is not all that reliable. Brute force check for small numbers is the best.

Aastha Dua: 2013-08-25 09:44:45

can anyone plz post some test cases.. i m getting WA again and again..but i think my code is giving correct outputs.. even for 0 to 10^44 also, i am getting 62762119217..plz reply asap.

Ashish Lavania: 2012-12-19 19:04:21

@Jack
Please tell me where my soln gives wrong Answer.
Please reply ASAP?
ID 8303476
Oops! Found It!

Last edit: 2012-12-19 19:07:22
Ehor Nechiporenko: 2012-08-16 09:26:45

Is the solution for
0 10^44
62762119217

(Tjandra Satria Gunawan)(曾毅昆): 2012-07-21 18:03:05

first step: bruteforce it --> TLE
next step: do precomputation --> WA
next step: semi_bruteforce+precomputation --> RE SIGSEGV
second last step: finally after some observation --> AC!!!
last step: fast I/O --> (+Silly mistake--> RE SIGSEGV/TLE/WA) #1st place ;)
I need ~6 hours to solve this problem perfectly...

:D: 2012-05-24 18:52:48

Is it like a led display?
0 <-> 0
1 <-> 1
8 <-> 8
2 <-> 5

or without 2<->5 pair?

AUTO RE: You should ignore the 2<->5 pair! Please clarify the description, since it really looks like we are asked about a seven-segment led display.

Last edit: 2012-05-24 19:11:34
Mitch Schwartz: 2012-03-01 23:15:12

Notice that these are not the same as palindromes. I think it's easy to miss if you don't read carefully.


Added by:jack(chakradarraju)
Date:2012-02-14
Time limit:1s-1.829s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Bytecode 2012