Beautiful numbers

题意翻译

Volodya 认为一个数字 $x$ 是美丽的,当且仅当 $x\in\mathbb{Z^+}$ 并且对于 $x$ 的每一个非零位上的数 $y$,都有 $y|x$。 你需要帮助他算出在区间 $[l,r]$ 中有多少个数是美丽的。 $t$ 组数据。 $1\le t\le 10,1\le l\le r\le 9\times 10^{18}$ 保证 $l,r$ 都是整数。

题目描述

Volodya 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.

输入输出格式

输入格式


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 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).

输入输出样例

输入样例 #1

1
1 9

输出样例 #1

9

输入样例 #2

1
12 15

输出样例 #2

2