Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits.

Also Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split the phone number into blocks of length k. The first block will be formed by digits from the phone number that are on positions 1, 2,..., k, the second block will be formed by digits from the phone number that are on positions k + 1, k + 2, ..., 2·k and so on. Pasha considers a phone number good, if the i-th block doesn't start from the digit b_{i} and is divisible by a_{i} if represented as an integer. 

To represent the block of length k as an integer, let's write it out as a sequence c_1, c_2,...,c_{k}. Then the integer is calculated as the result of the expression c_1·10^{k} - 1 + c_2·10^{k} - 2 + ... + c_{k}.

Pasha asks you to calculate the number of good phone numbers of length n, for the given k, a_{i} and b_{i}. As this number can be too big, print it modulo 10^9 + 7. 


-----Input-----

The first line of the input contains two integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ min(n, 9)) — the length of all phone numbers and the length of each block, respectively. It is guaranteed that n is divisible by k.

The second line of the input contains n / k space-separated positive integers — sequence a_1, a_2, ..., a_{n} / k (1 ≤ a_{i} < 10^{k}).

The third line of the input contains n / k space-separated positive integers — sequence b_1, b_2, ..., b_{n} / k (0 ≤ b_{i} ≤ 9). 


-----Output-----

Print a single integer — the number of good phone numbers of length n modulo 10^9 + 7.


-----Examples-----
Input
6 2
38 56 49
7 3 4

Output
8

Input
8 2
1 22 3 44
5 4 3 2

Output
32400



-----Note-----

In the first test sample good phone numbers are: 000000, 000098, 005600, 005698, 380000, 380098, 385600, 385698.

Difficulty: interview

Starter code:

Solutions:
import math

n, k = [int(x) for x in input().split()]

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

c = 1
for i in range(n // k):
    count = (10 ** k - 1) // a[i] + 1
    mmin = b[i] * (10 ** (k-1))
    mmax = (b[i] + 1) * (10 ** (k-1)) - 1
    mcount = mmax // a[i] - math.ceil(mmin / a[i]) + 1
    c = (c * (count - mcount)) % ((10 ** 9) + 7)

print(c)


n, k = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

def solve(n, k, As, Bs):
    mod = 10 ** 9 + 7
    c = 1
    for a, b in zip(As, Bs):
        c *= f(a, b, k, mod)
        c %= mod
    return c

def f(a, b, k, mod):
    total = (10 ** k - 1) // a + 1
    p = ((b + 1) * (10 ** (k-1)) - 1) // a
    q = (b * (10 ** (k-1)) - 1) // a
    return (total - p + q) % mod


print(solve(n, k, As, Bs))

# import sys
# n = int(input())
# s = input().strip()
# a = [int(tmp) for tmp in input().split()]
# for i in range(n):
n, k = [int(tmp) for tmp in input().split()]
a = [int(tmp) for tmp in input().split()]
b = [int(tmp) for tmp in input().split()]
BIG = 10 ** 9 + 7
m = n // k
ans = [0] * m
for i in range(m):
    ans[i] = (10 ** k + a[i] - 1) // a[i]
    x = 10 ** (k - 1) * b[i] % a[i]
    if x != 0:
        ans[i] -= (10 ** (k - 1) + x + a[i] - 1) // a[i] - 1
    else:
        ans[i] -= (10 ** (k - 1) + x + a[i] - 1) // a[i]
all_ans = 1
for i in range(m):
    all_ans = (all_ans * ans[i]) % BIG
print(all_ans)

from math import ceil
from math import floor

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ln = n // k
p = 1
mod = 1000000007

for i in range(ln):
    tmp = (10 ** k - 1) // a[i] + 1
    l = ceil(b[i] * (10 ** (k - 1)) / a[i])
    r = floor(((b[i] + 1) * (10 ** (k - 1)) - 1) / a[i])
    tmp -= r - l + 1
    p = (p * tmp) % mod

print(p)



"""
Codeforces Round #330 (Div. 2)

Problem 595 B

@author yamaton
@date 2015-11-08
"""

import itertools as it
import functools
import operator
import collections
import math
import sys

BASE = 1000000007

def count(k, a, b):
    x = count_multiples(a, 0, 10**k-1)
    y = count_multiples(a, b * 10**(k-1), (b + 1) * 10**(k-1) - 1)
    return  x - y


def count_multiples(a, _from, _to):
    if _from == 0:
        return _to // a - (_from - 1) // a
    else:
        return _to // a - (_from - 1) // a


def solve(xs, ys, n, k):
    result = 1
    for (a, b) in zip(xs, ys):
        result = (result * count(k, a, b)) % BASE
    return result

def main():
    [n, k] = [int(i) for i in input().strip().split()]
    xs = [int(i) for i in input().strip().split()]
    ys = [int(i) for i in input().strip().split()]
    assert len(xs) == len(ys) == n // k
    result = solve(xs, ys, n, k)
    print(result)


def __starting_point():
    main()

__starting_point()

import sys

n, k = sys.stdin.readline().split()
n = int(n)
k = int(k)

a = [int(x) for x in sys.stdin.readline().split()]
b = [int(x) for x in sys.stdin.readline().split()]

MOD = (10 ** 9) + 7
res = 1

for i in range(0, n // k):
	lo =  b[i]      * (10 ** (k - 1)) - 1
	up = (b[i] + 1) * (10 ** (k - 1)) - 1
	tmp = ( ((10 ** k) - 1) // a[i]) - (up // a[i]) + (lo // a[i]) + 1
	res = res * tmp
	res = res % MOD

print(res)

def get_multypler(k, a, b):
    res = (10 ** k - 1) // a + 1
    bad_residue = (a - ((10 ** (k - 1)) * b) % a) % a
    suf = (10 ** (k - 1)) - 1
    minus = suf // a + (1 if (bad_residue <= suf % a) else 0)
    return res - minus




n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 1
for i in range(n // k):
    ans *= get_multypler(k, a[i], b[i])
    ans %= 10 ** 9 + 7

print(ans)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time
MM = 1000000007

def func(a, b, k):
    if b == 0:
        return(divmod(10**k-1, a)[0]-divmod(10**(k-1)-1, a)[0])
    else:
        return(divmod(10**k-1, a)[0]-divmod((b+1)*10**(k-1)-1, a)[0]+divmod(b*10**(k-1)-1, a)[0])+1

(n, k) = (int(i) for i in input().split())
a      = [int(i) for i in input().split()]
b      = [int(i) for i in input().split()]

start = time.time()

s = 1
for i in range(divmod(n, k)[0]):
    s *= func(a[i], b[i], k)
    s = divmod(s, MM)[1]


print(s)
finish = time.time()
#print(finish - start)


n, k = [int(i) for i in input().split()]
sum = 1
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
for i in range(n // k):
    if n == 0:
        x = (10 ** k - 1) // a[i] - ((b[i] + 1) * 10 ** (k-1) - 1) // a[i]
    else:
        x = (10 ** k - 1) // a[i] - ((b[i] + 1) * 10 ** (k-1) - 1) // a[i] + (b[i] * 10 ** (k-1) - 1) // a[i] + 1
    sum *= x
    sum %= 10 ** 9 + 7
print(sum)


from math import ceil

n,k = list(map(int,input().split()))

arr1 = list(map(int,input().split()))
arr2 = list(map(int,input().split()))

p = 10**k

ans = 1

for i in range(n//k):
    x,y = arr1[i],arr2[i]
    a,b = y * 10**(k - 1),(y + 1) * 10**(k - 1)
    ans *= ceil(p / x) - (ceil(b / x) - ceil(a / x))
    ans %= 10**9 + 7

print(ans)


n, k = list(map(int, input().split()))

a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = 10 ** (k - 1)
res = 1;
q = 10 ** 9 + 7
for i in range(n // k):
    res1 = (((t * 10) - 1) // a[i] + 1) % q;
    z = ((t * b[i]) - 1) // a[i] + 1
    if (b[i] == 0):
        z = 0
    x = (((t * b[i] + t - 1) // a[i])) + 1
    res1 = (res1 - x + z) % q
    res = (res * res1) % q
print(res)


from math import *
N, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 1
M = 10**9 + 7
p = 10**K - 1
u = 10**(K - 1)
for i in range(N // K):
    ans *= (p // a[i] + 1 - ((u * (b[i] + 1) + a[i] - 1) // a[i] - (b[i] * u + a[i] - 1) // a[i]))
    ans %= M
print((ans + M) % M)

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

answer = list()

for i in range(n//k):
    res = 0
    m = '1'+'0'*k
    m = int(m)-1
    q = str(b[i]) + '9' * (k-1)
    q = int(q)
    c = str(b[i]-1) + '9' * (k-1)
    c = int(c)
    c = max(c,-1)
    #print(m,q,c)
    res = (m//a[i]+1) - q//a[i] + c//a[i]
    answer.append(res)

resa = 1
#print(answer)
if sum(answer)==0:
    print(0)
else:
    for i in answer:
        resa = (resa*i)%1000000007
    print(resa)

n, k = list(map(int, input().split()))
ara = list(map( int, input().split()))
arb = list(map( int, input().split()))
sum1 = 1;
p_k = 10**k
p_k1 = 10**(k - 1)
p_k2 = 10**(k - 2)
M = 10**9 + 7
for i in range(n // k):
    k = 0
    if (p_k % ara[i] == 0):
        k = -1
    if ((arb[i] + 1) * p_k1 % ara[i] == 0):
        k = k + 1
    if ((arb[i]) * p_k1 % ara[i] == 0):
        k = k - 1
    sum1 *= p_k // ara[i] - p_k1 * (arb[i] + 1) // ara[i] + p_k1 * (arb[i]) // ara[i] + k + 1
    #first = p_k1 * arb[i] // ara[i] * (ara[i] + 1)
    #print(p_k // ara[i] + k + 1, p_k1 * (arb[i] + 1) // ara[i], p_k1 * (arb[i]) // ara[i])
    #sum1 *= p_k // ara[i] + 1 - p_k1 // first
    
    sum1 = sum1 % M
print(sum1 % (10**9+7))


import math
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))



def calc_ans(k,a,b):
	div = (10**k-1)//a + 1
	
	b_min = b*10**(k-1)
	b_max = (b+1)*10**(k-1) - 1


	d_min_inc = math.ceil(b_min/a)
	d_max_inc = math.floor(b_max/a)
	# if d_min_inc*a > b_max:
	# 	return div
	# else:


	# print (k,a,b,div,div - (d_max_inc - d_min_inc + 1))

	return div - (d_max_inc - d_min_inc + 1)

p = 10**9 + 7

ans = 1
for ai,bi in zip(a,b):
	ans = (ans*calc_ans(k, ai, bi)) % p

print(ans)

def easy_calc(k,a,b):
	ans = 0
	for i in range(10**k):
		c = str(i)
		first = int(c[0]) if len(c) == k else 0
		if i%a == 0 and not first==b:
			ans += 1
	return ans

# import random
# for i in range(100):
# 	k = random.randrange(4,5)
# 	a = random.randrange(1,10**k)
# 	b = random.randrange(0, 10)
# 	if easy_calc(k,a,b) != calc_ans(k,a,b):
# 		print(k,a,b, easy_calc(k,a,b), calc_ans(k,a,b))
# 		1/0


s=input()
ast=s.split(' ')
n,k=int(ast[0]),int(ast[1])
s=input()
a=[int(i) for i in s.split(' ')]
s=input()
b=[int(i) for i in s.split(' ')]
L=n//k
p=10**k
r=10**(k-1)
rez=1
for i in range(L):
    cnt=0
    if b[i]>0:
        cnt+=(b[i]*r-1)//a[i]
        cnt+=(p-1)//a[i]
        cnt-=((b[i]+1)*r-1)//a[i]
        rez*=cnt+1
    else:
        cnt+=(p-1)//a[i]
        cnt-=(r-1)//a[i]
        rez*=cnt
    rez=rez%(10**9+7)
print(rez)


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = n//k
ans = 1
for i in range(c):
    t_ans = ((10**k - 1)//a[i]+1) + (b[i]*10**(k-1))//a[i] - ((b[i]+1)*10**(k-1))//a[i]
    if (b[i]*10**(k-1))%a[i] == 0:
        t_ans -= 1
    if ((b[i]+1)*10**(k-1))%a[i] == 0:
        t_ans += 1    
    ans *= t_ans
    ans = ans%(10**9 +7)
print(ans)
    


#!/usr/bin/env python
# -*- coding: utf-8 -*-

n,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 1

for i in range(n//k):
    count = 1 + (10**k - 1)//A[i]
    count -= (10**(k-1) * (B[i] + 1) - 1) // A[i] - (10**(k-1) * B[i] - 1) // A[i]

    ans = ans * count % (10**9 + 7)

print(ans)


n,k = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
mod = 1000000007
ans = 1
for x in range(0,n//k):
    po = 10**(k-1)
    p = c[x]*po
    q = (c[x]+1)*po
    res = 0
    if p%b[x] == 0:
        res -= 1
    if q%b[x] == 0:
        res += 1
    if (po*10)%b[x] == 0:
        res -= 1
    res += 1
    res += 10*po//b[x] - q//b[x] + p//b[x]
    ans = ((ans%mod)*(res%mod))%mod
print(ans)


p = 10**9+7
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 1
for i in range(n//k):
	cnt = (10**k-1)//a[i] - (10**(k-1)*(b[i]+1)-1)//a[i]
	if b[i] != 0:
		cnt += (10**(k-1)*b[i]-1)//a[i] + 1
	ans = ans * cnt % p
print (ans)

n,k = map(int,input().split())
b = list(map(int,input().split()))
c = list(map(int,input().split()))
mod = 1000000007
ans = 1
for x in range(0,n//k):
    po = 10**(k-1)
    p = c[x]*po
    q = (c[x]+1)*po
    res = 0
    if p%b[x] == 0:
        res -= 1
    if q%b[x] == 0:
        res += 1
    if (po*10)%b[x] == 0:
        res -= 1
    res += 1
    res += 10*po//b[x] - q//b[x] + p//b[x]
    ans = ((ans%mod)*(res%mod))%mod
print(ans)

p = 10**9+7
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 1
for i in range(n//k):
    cnt = (10**k-1)//a[i] - (10**(k-1)*(b[i]+1)-1)//a[i]
    if b[i] != 0:
        cnt += (10**(k-1)*b[i]-1)//a[i] + 1
    ans = ans * cnt % p
print (ans)

from math import *
MOD=10**9+7
n,k=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
temp= pow(10,k-1)
ans=1
for i in range(len(a)):
	totDiv = ceil((temp*10)/a[i])
	num1= temp*(b[i])
	num2= temp*(b[i]+1)
	smaller= ceil(num1/a[i])
	larger=ceil(num2/a[i])
	totDiv+=(smaller-larger)
	ans= (ans*totDiv)%MOD
print(int(ans))


mask = 10 ** 9 + 7

def count(a, x):
	return x // a + 1

n, k = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

big = 10 ** k - 1
small = 10 ** (k - 1)
result = 1

for i in range(n // k):
	a, b = aa[i], bb[i]
	sum = 0
	sum += count(a, big)
	sum -= count(a, (b + 1) * small - 1)
	if b != 0:
		sum += count(a, b * small - 1)
	result = (result * sum) % mask

print(result)