ADST01 - Truncky Numbers


Asutosh is very passionate about numbers. he has found a new type of numbers and calls them 'truncky numbers'.

He has challenged his friend Shantanu to find the sum of first n truncky numbers. As shantanu is weak at programming, help him to complete his challenge.

A truncky number is defined as:

  1. sum of digits in the number is of the form (5*k + 1) where k = number of digits.
  2. absolute difference between any two digits in the number is either 0 or 1.
  3. digits are in the non decreasing order.

Input

the first line contains T (number of test cases). Each test contains only one integer n.

Output

Print in single line sum of first n truncky numbers modulo 10^9 + 7.

Each output in new line.

Constraints

T <= 30

N <= 10^17

Example

Input:
1
2

Output:
62

hide comments
mkfeuhrer: 2016-06-22 21:12:00

my love for python grows more!! simple math formula :) AC !

prakash_reddy: 2016-01-11 11:14:13

nice question @Ashutosh....

Diksha Jaiswal: 2016-01-03 12:02:40

good problem

geoffreymace7: 2015-10-16 08:31:39

Great question!

Last edit: 2015-10-16 08:31:56
Daksh: 2015-10-05 19:33:34

12 class math..

adi_tri: 2015-09-17 18:14:15

nice question bhai..!!

Advitiya: 2015-09-17 07:41:06

Silly Mistakes 3WA, finally AC :')

divide_by_1: 2015-09-17 06:42:56

what is answer for 10000000000
pls give some hint

Last edit: 2015-09-17 08:08:12
Anshul jain: 2015-09-16 17:51:51

after many WA finally the code got accepted!!!

Last edit: 2015-09-16 18:05:17

Added by:Voldemort
Date:2015-09-12
Time limit:0.100s-1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: GOSU
Resource:own