P18670 [HackerEarth] Background:
提高
题目描述

Background:
Mehta's friend Verma has challenged him in a maths puzzle. The puzzle involves playing with digits, their product and square root.

Task:
Numbers which have product of their digits as perfect square in their decimal representation are called Fancy Numbers. So, you have to report the count of Fancy Numbers having length less than or equal to given number N. Length of the number is defined as number of digits in its decimal representation.

Input:
First Line of the input contains number of test cases T.
Next T Lines contain a single number N denoting the maximum length.

Output:
Output the count of Fancy Numbers having length less than or equal to given number N in a separate line for all test cases T modulo 10^9 + 7.

Note:
0 is a perfect square and has length 1.
Any number of length X does not have leading zeros i.e one is represented as 1 and not 01, 001.

Constraints:
Subtask 1:
1 ≤ T ≤ 10
1 ≤ N ≤ 10000
Subtask 2:
1 ≤ T ≤ 5
1 ≤ N ≤ 10^18

SAMPLE INPUT
4
1
2
3
4

SAMPLE OUTPUT
4
30
312
3560

Explanation

Case 1:
Fancy numbers of length less than equal to 1 are:- [0,1,4,9] as their product itself is [0,1,4,9]. Hence, there are only 4 Fancy numbers of length less than equal to 1.

输入格式

见题面

输出格式

见题面

样例输入
10 41 8467 6334 6500 9169 5724 1478 9358 6962 4464
样例输出
186059188 37783292 278886771 42973753 469266648 73519915 699565792 745297726 662862465 18443258