Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

No tag edit access

The problem statement has recently been changed. View the changes.

×
D. Beautiful numbers

time limit per test

4 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputVolodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful 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 beautiful 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 *l*_{i} and *r*_{i} (1 ≤ *l*_{i} ≤ *r*_{i} ≤ 9 ·10^{18}).

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

Output

Output should contain *t* numbers — answers to the queries, one number per line — quantities of beautiful numbers in given intervals (from *l*_{i} to *r*_{i}, inclusively).

Examples

Input

1

1 9

Output

9

Input

1

12 15

Output

2

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/11/2021 23:21:25 (j2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|