Lucky Number

All submissions for this problem are available.
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Let F(X) equals to the number of lucky digits in decimal representation of X. Chef wants to know the number of such integers X, that L ≤ X ≤ R and F(X) is a lucky number. Help him and calculate that number modulo 10^{9}+7.
Input
First line contains one integer T, the number of test cases. Each of the following T lines contains two space separated positive integers L and R.
Output
For each of the T test cases print one integer, the number of such X, that L ≤ X ≤ R and F(X) is a lucky number, modulo 1000000007.
Constraints
1 ≤ T ≤ 10
1 ≤ L ≤ R ≤ 10^{1000}
Example
Input: 4 1 100 1 10000 1 100000 4444 4447 Output: 0 16 640 2
Notes
First test case: of course, any number of less than 4 digits can't contain lucky number of lucky digits, so the answer is 0.
Second test case: 16 required numbers are 4444 4447 4474 4477 4744 4747 4774 4777 7444 7447 7474 7477 7744 7747 7774 7777.
Third test case: there are 640 required lucky numbers. Some of them are 4474, 14747, 41474, 77277, 44407, 74749.
Fourth test case: the only two required numbers are 4444 and 4447.
Author:  witua 
Tester:  anton_lunyov 
Editorial  http://discuss.codechef.com/problems/LUCKY2 
Tags  easy march12 witua 
Date Added:  11112011 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 
http://www.codechef.com/MARCH
can you plz explain me the
@jigyasu, when L = 8910 and R
For the first Test case why
why not 47 and 74 for the
Thanks bodmas, It's
This can't be an easy
I ran other successful
anyone can explain the
the third case cannot hav 640
what is the use of 1000000007
"Third test case: there are
even i dint get how 14747 can
i am getting time limit
@all who are having doubts:
i am also not getting how
@simac: 14747 is not lucky.
for 1 to 10000 the lucky no
@viking: actually all
is the 1100000 case correct
i am not able to optimize my
hmmmmmmmm
The question is not "how many
where is the time limit? 1
@jerryczz : Time limit is
Is time limit for all
@cdwijayarathna, no, for java
Hello, can someone explain me
Its is given that 47 is lucky
@rarunkavin 47 is lucky
@gaurav 4<=count digits
47 can be lucky
a no. will be lucky iff it
this program is quite well
Has anyone tried to solve
This problem is definitely
I tried in C language , , why
im getting exact sample
my program is working fine in
Sorry, but this is a horrid
@georgelucas= Question says
The problem asks you to find