#P1943. Perfectnumber

Perfectnumber

    hrdv is a lovely boy but his taste is strange. It seems to him that a positive integer number is perfect if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of perfect numbers in given ranges.

Input

The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two natural numbers li and ri (1 ≤ li ≤ ri ≤ 9 ·10^18).

Output

Output should contain t numbers — answers to the queries, one number per line — quantities of perfect numbers in given intervals (from li to ri, inclusively).

Sample Input

2
1 9
12 15

Sample Output

9
2

HINT

Source