#2250. Pku3899 The Lucky Numbers

Pku3899 The Lucky Numbers

题目描述

John and Brus are freshmen at the primary school.Their first home task is to learn some integer numbers.It is not so hard for the guys and they decide to impress their teacher by learning all lucky numbers between AA and BB.inclusive.

As you already know from the previous year contest 44 and 77 are lucky digits,and all the other digits are not lucky.A lucky number is a number that contains only lucky digits in decimal notation.

After learning all lucky numbers in [A,B][A,B] range John and Brus still have some free time and now they decide to learn additionally each lucky number NN that is out of [A,B][A,B] range,but the reversed number of NN is in this range.Here reversed number of NN is the number NN written in decimal notation,but the order of digits is reversed.For example,the reversed number of 447447 is 744744 and reversed number of 774474444774474444 is 444474477444474477

You are given integers AA and BB and your task is to find the total number of lucky numbers learned by John and Brus.

输入格式

本题有多组数据

The first line contains single integer TT - the number of test cases.Each test case consists of a single line containing two integers AA and BB separated by a single space.

输出格式

For each test case print a single line containing the total number of lucky numbers learned by John and Brus.

2 
1 100
44 47
6
3

数据规模与约定

100%100\% 的数据满足:1T741 \le T \le 741AB10501 \le A \le B \le 10^{50}

题目来源

Seerc2009