All Submissions


PROBLEM STATEMENT

On a digital display, digits 0,1,2,5,8 are mirror images of 0,1,5,2,8.
A vertical number is one for which its mirror image is the same as the original number. Given two integers(A and B), find the number of vertical numbers between the two numbers (inclusive).

Mirror Images are taken about a vertical axis.

INPUT

First line of input contains T,the number of test cases. The next T lines contain two integers A and B in each line.

OUTPUT

Print the number of vertical numbers between A and B .

CONSTRAINTS

A will represent an integer between 0 and 10^18, inclusive.
B will represent an integer between A and 10^18, inclusive.
Both A and B will have no extra leading zeros.

SAMPLE INPUT


3
2 100
0 1
525 1234


SAMPLE OUTPUT


5
2
6


Problem Setter: Anjali Singh

Languages: C,C++,C#,Java,JavaScript,Pascal,Perl,PHP,Python,Ruby

Time Limit: 2 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0