lucky8_13795
A Little Elephant from the Zoo of Lviv likes lucky numbers very much. Everybody knows that the 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 F4(X) be the number of digits 4 in the decimal representation of X, and F7(X) be the number of digits 7 in the decimal representation of X. For example, F4(456) = 1, F4(444) = 3, F7(1) = 0, F7(747) = 2. The Little Elephant wants to know the largest product F4(X) ∙ F7(X), where L ≤ X ≤ R. In other words he wants to know the value
 max{F4(X) ∙ F7(X) : L ≤ X ≤ R}.


Input
 The first line of the input file contains an integer T, the number of test cases. T test cases follow. The only line of each test case contains two integers L and R separated by exactly one space.


Output
 For each test case output a single line containing the answer for the corresponding test case.


Constraints

1 ≤ T ≤ 1000

1 ≤ L ≤ R ≤ 10^18

Example

Input:
3
1 10
1 100
47 74

Output:
0
1
1


Explanation
In both second and third test cases the maximal product is achieved at the numbers 47 and 74.
numOfTests = int(raw_input())

def computeMaxProd(N, N4, N7):
    if N == 0:
        return N4*N7
    
    x = (N+N7-N4)/2

    
    if x < 0:
        x = 0
        y = x+1
    elif x > N:
        x = N
        y = x
    else:
        y = x+1

    

    
    return max( (x+N4)*(N-x+N7) , (y+N4)*(N-y+N7))

def defMaxProd(L, R, N=0, N4=0, N7=0):
    if not L:
        return computeMaxProd(N, N4, N7)
            
    r = int(R[0])
    l = int(L[0])

    if not r - l:
        if r == 7:
            N7 += 1
        elif r == 4:
            N4 += 1

        L = L[1:]
        R = R[1:]

        
        return defMaxProd(L, R, N4=N4, N7=N7)
        

    elif r - l == 1:
        rN4 = lN4 = N4
        rN7 = lN7 = N7

        if r == 7:
            rN7 += 1
        elif r == 4:
            rN4 += 1
        elif l == 7:
            lN7 += 1
        elif l == 4:
            lN4 += 1

        L = L[1:]
        R = R[1:]

        return max(defMaxProd(['0']*len(L), R, N4=rN4, N7=rN7), defMaxProd(L, ['9']*len(R), N4=lN4, N7=lN7))
        
    
    elif r - l > 1:
        L = L[1:]
        R = R[1:]
        N += len(R) 

        maxprod = 0
        
        if 4 in map(lambda x: x%10, range(l+1, r)):
            maxprod = computeMaxProd(N=N,N4=N4+1,N7=N7)
        
        if 7 in map(lambda x: x%10, range(l+1, r)):
            maxprod = max( maxprod, computeMaxProd(N,N4,N7+1))
            
        if not maxprod:
            maxprod = computeMaxProd(N=N,N4=N4,N7=N7)

        if r == 7:
            maxprod = max(maxprod, defMaxProd(['0']*len(L), R, N4=N4, N7=N7+1))
        if r == 4:
            maxprod = max(maxprod, defMaxProd(['0']*len(L), R, N4=N4+1, N7=N7))
        if l == 7:
            maxprod = max(maxprod, defMaxProd(L, ['9']*len(R), N4=N4, N7=N7+1))
        if l == 4:
            maxprod = max(maxprod, defMaxProd(L, ['9']*len(R), N4=N4+1, N7=N7))
        
        return maxprod

for test in xrange(numOfTests):
    L, R = raw_input().split()

    L = list(L)
    R = list(R)

    L = ['0']*(len(R)-len(L)) + L

    print defMaxProd(L, R, N=0, N4=0, N7=0)