GEEKOUNT - EVEN COUNT

Let f(x) be the product of digits of a number.

Given L and R, find the number of values of 'i' such that L ≤ i ≤ R and f(i) is even.

Input

The first line consists of an integer t, the number of test cases. For each test case, you are given the two integers L and R.

Output

For each test case, print the number of values of 'i' such that L ≤ i ≤ R and f(i) is even.

Constraints

1 ≤ t ≤ 100

1 ≤ L ≤ R ≤ 1000000000

Sample

Input:
2
2 12
4 23

Output:
6
12

Added by:cegprakash
Date:2013-01-15
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: BF
Resource:problem setter: rkarthikeyan

hide comments
2013-04-14 22:22:54 Nick
in sample test case above, between 4 23, is it 10 (total of even number)?
2013-04-14 22:22:54 Orchid
i'm also getting the same.
2013-04-14 22:22:54 Otniel Yehezkiel
maybe 118926
2013-04-14 22:22:54 Orchid
1 123456
will the output be 118926 or 118927?
2013-04-14 22:22:54 Otniel Yehezkiel
make the brute force 1st, then you can see the pattern from your brute force's program output

Last edit: 2013-03-17 04:27:50
2013-04-14 22:22:54 NotMalvika
more test cases-
1 10
1 1000000000
10 100
12 3456
99 1000
101 107
1001 1111
123456789 987654321
999999999 999999999
1000000000 1000000000
Answers - 5 997558595 66 3121 776 7 110 862400658 0 1

Last edit: 2013-10-18 11:23:11
2013-04-14 22:22:54 Orchid
@cegprakash getting WA on test judge 3 again and again..please see submission id 8907764 and help me if possible..
2013-04-14 22:22:54 Haijun Deng
@!..TomB R@ideR..!
Answer for 8 9 is 1, right? 8 - 1
2013-04-14 22:22:54 Goldie
Nice problem :)
2013-04-14 22:22:54 LeoDaVinci
@Haijun Deng : 1
8 9
check this one....!!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.