EXcellent Number
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

We call a number EXcellent if it divided by  euqals   or it contains the number , see sample for details.

Now we want to know how many EXcellent numbers are between  ?

Since this number can be very large, print the remainder when it's divided by lovely .

输入描述:

The first line contains an integer  — the number of test cases you need to solve.

The only line of each test case contains  integer  without leading zeros.

输出描述:

For each test case, print the result mod lovely .
示例1

输入

复制
3
1 1
2 12
666 233

输出

复制
3
11
828654121

说明

In the first example, there are 0,1,10

In the second example, there are 0,11,12,22,33,44,55,66,77,88,99