The Petrozavodsk camp takes place in about one month. Jafar wants to participate in the camp, but guess what? His coach is Yalalovichik.
Yalalovichik is a legendary coach, famous in the history of competitive programming. However, he is only willing to send to the camp students who solve really hard problems on Timus. The deadline that Yalalovichik set before has passed and he refuses to send Jafar to the camp.
Jafar decided to make Yalalovichik happy in hopes of changing his decision, so he invented a new sequence of numbers and named them Yalalovichik numbers. Jafar is writing a research paper about their properties and wants to publish it in the Science Eagle yearly journal.
A Yalalovichik number is created in the following way:
- Consider an integer $N$ in decimal notation; let's call it the base of the Yalalovichik number $Y_N$. $N$ may not contain the digit $0$.
- Treat $N$ as a decimal string. Compute all left shifts of this string $N_0, N_1, \ldots, N_{|N|-1}$ ($|N|$ denotes the number of digits of $N$); specifically, $N_k$ denotes the string formed by moving the first $k$ digits of $N$ to the end in the same order.
- Concatenate the strings $N_0, N_1, \ldots, N_{|N|-1}$. The resulting string is the decimal notation of $Y_N$.
For example, if $N = 123$, the left shifts are $123, 231, 312$ and thus $Y_N = 123231312$.
You are given the base $N$. Calculate the value of $Y_N$ modulo $10^9+7$.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains a single decimal integer $N$.

-----Output-----
For each test case, print a single line containing one integer — the value of the Yalalovichik number $Y_N$ modulo $10^9+7$.

-----Constraints-----
- $1 \le T \le 200$
- $|N| \le 10^5$
- $N$ does not contain the digit $0$
- the sum of $|N|$ over all test cases does not exceed $10^6$

-----Example Input-----
1
123

-----Example Output-----
123231312

Starter code:

Solutions:
M = 10 ** 9 + 7
for _ in range(int(input())):
    s,p,m,r = list(map(int, input())),0,1,0
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)

M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)

    

T=int(input())
m=10**9+7
while(T>0):

    num=list(map(int,input()))
    n=0
    for i in range(len(num)):
        n=(n*10)
        n=(n+num[i])%m
    rs=n
    y=10**(len(num))%m
    for i in range(len(num)-1):
        n=(n*10-(y-1)*num[i])%m
        rs=(rs*(y)+n)%m
    print(rs)
    T-=1

m=10**9+7
T=int(input())
while(T>0):
    num=list(map(int,input()))
    n=0
    for i in range(len(num)):
        n=(n*10)%m
        n=(n+num[i])%m
    rs=n
    y=10**(len(num))%m
    for i in range(len(num)-1):
        n=(n*10-(y-1)*num[i])%m
        rs=(rs*(y)+n)%m
    print(rs)
    T-=1

M = 10 ** 9 + 7
for _ in range(int(input())):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)

M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)

t = int(input())
decimal = [1]
mod = 10**9 + 7
for i in range(10**5 + 1):
    decimal.append((decimal[-1]*10) % mod)


def num(n):
    ans = 0
    length = len(n)
    for i in range(0, length):
        ans += (int(n[i])*decimal[length - i - 1])%mod

    return ans


for i in range(0, t):
    n = input()
    length = len(n)
    p = (10 ** length)%mod
    p1 = (10 ** (length-1))%mod
    mul = [1]
    for j in range(0, length-1):
        mul.append((mul[-1]*p)%mod)
    value = num(n)

    ans = 0
    for j in range(length-1, -1, -1):
        temp = (value * mul[j])%mod
        ans += temp
        value = value - int(n[length - 1 - j]) * p1
        value = (value * 10 + int(n[length - 1 - j])) % mod
    print(ans%mod)

M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)

M = 10 ** 9 + 7
t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)

M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = input()
    p, m = 0, 1
    for d in reversed(s):
        p += (ord(d) - 48) * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * (ord(d) - 48)) % M
    print(r)

from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import functools
import sys
import math
MAX = sys.maxsize
MAXN = 10**6+10
MOD = 10**9+7
def isprime(n):
    n = abs(int(n))
    if n < 2:
        return False
    if n == 2: 
        return True    
    if not n & 1: 
        return False
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False
    return True

def mhd(a,b,x,y):
    return abs(a-x)+abs(b-y)

def numIN():
    return(map(int,sys.stdin.readline().strip().split()))

def charIN():
    return(sys.stdin.readline().strip().split())

t = [0]*1000010

def create(a,n):
	global t
	for i in range(n,2*n):
		t[i] = a[i-n]
	for i in range(n-1,0,-1):
		t[i] = t[2*i]+t[2*i+1]


def cal(n,k):
	res = 1
	c = [0]*(k+1)
	c[0]=1
	for i in range(1,n+1):
	    for j in range(min(i,k),0,-1):
	        c[j] = (c[j]+c[j-1])%MOD
	return c[k]


for i in range(int(input())):
	n = int(input())
	a = str(n)
	l = len(a)
	ans = n
	p1 = pow(10,l,MOD)
	p2 = pow(10,l-1,MOD)
	for j in range(l-1):
		n-=(int(a[j])*p2)
		n%=MOD
		n*=10
		n%=MOD
		n+=int(a[j])
		n%=MOD
		ans*=p1
		ans%=MOD
		ans+=n
		ans%=MOD

	print(ans)













t = int(input())
for _ in range(t):
    s = input()

    if len(s) == 1:
        print(s)

    else:
        mod = 10**9+7
        l = len(s)
        curr = 0
        for i in s:
            curr *= 10
            curr += int(i)
            curr %= mod

        ans = curr
        p1 = 1
        p2 = 1

        for i in range(l):
            p1 *= 10
            p1 %= mod

        for i in range(l-1):
            p2 *= 10
            p2 %= mod

        for i in range(l-1):
            curr -= (p2 * int(s[i])) % mod
            curr *= 10
            curr += int(s[i])
            curr %= mod
            ans *= p1
            ans %= mod
            ans += curr
            ans %= mod

        print(ans)


M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    ans = 0
    for d in s:
        ans = (ans * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(ans)

t=int(input())
modval=(10**9)+7
for _ in range(t):
	val=list(input())
	inp=0
	res=0
	multiplier=1
	for i in val:
		inp=((inp*10)+int(i))%modval
		multiplier=(multiplier*10)%modval
	for i in val:
		res=((res*multiplier)+inp)%modval
		inp=(inp*10 - (multiplier-1)*int(i))%modval
	print(res)

M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)


MOD=10**9+7
def main():
	t=int(input())
	for i in range(t):
		s=list(map(int,input()))
		p,m=0,1
		for d in reversed(s):
			p+=d*m
			m=m*10%MOD
		r=0
		for d in s:
			r=(r*m+p)%MOD
			p=(p*10-(m-1)*d)%MOD
		print(r)

















main()

M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)


from operator import mul

M = 10 ** 9 + 7
N = 100001

p10 = [None] * N
k = 1
for i in range(N):
    p10[i] = k
    k = k * 10 % M 

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    m = p10[len(s)]
    p = sum(map(mul, reversed(s), p10))
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)


from operator import mul

M = 10 ** 9 + 7
N = 100001

p10 = [None] * N
p10[0] = 1
for i in range(1, N):
   p10[i] = p10[i - 1] * 10 % M 

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    m = p10[len(s)]
    p = sum(map(mul, reversed(s), p10))
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)


M = 10 ** 9 + 7
N = 100001

p10 = [None] * N
p10[0] = 1
for i in range(1, N):
   p10[i] = p10[i - 1] * 10 % M 

t = int(input())
for _ in range(t):
    s = list(map(ord, input()))
    p = sum((x - 48) * y for x, y in zip(reversed(s), p10))
    m = p10[len(s)]
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * (d - 48)) % M
    print(r)


from operator import mul

M = 10 ** 9 + 7
N = 100001

p10 = [None] * N
p10[0] = 1
for i in range(1, N):
   p10[i] = p10[i - 1] * 10 % M 

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p = sum(map(mul, reversed(s), p10))
    m = p10[len(s)]
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)


M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)


M = 10 ** 9 + 7

t = int(input())
for _ in range(t):
    s = list(map(int, input()))
    p, m = 0, 1
    for d in reversed(s):
        p += d * m
        m = m * 10 % M
    r = 0
    for d in s:
        r = (r * m + p) % M
        p = (p * 10 - (m - 1) * d) % M
    print(r)


T = int(input())
for i in range(T):
    N = int(input())
    ans = N
    M = N
    L = len(str(N))
    ls = list(str(N))
    key = (10**L)%(10**9+7)
    for i in range(L-1):
        a0 = int(ls[i])
        M = (10*M + a0*(1-key))%(10**9+7)
        ans = (ans*key + M)%(10**9+7)
    print(ans%(10**9+7))