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: MEDIUM_HARD

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)


import sys
(n, k) = map(int, input().split())

def getNumber(l, r, num):
	d = l // num
	if d * num < l:
		d += 1
	l = num * d
	if l > r:
		return 0
	return (r - l) // num + 1
ans = 1
mod = 10 ** 9 + 7
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(0, n // k):
	if b[i] == 0:
		ans *= getNumber(10 ** (k - 1), 10 ** k - 1, a[i]) % mod
	elif b[i] == 9:
		ans *= getNumber(0, 10 ** k - 1 - 10 ** (k - 1), a[i]) % mod
	else:
		ans *= (getNumber(0, 10 ** (k - 1) * b[i] - 1, a[i]) % mod + getNumber(10 ** (k - 1) * (b[i] + 1), 10 ** k - 1, a[i]) % mod) % mod
	ans %= mod
print(ans)


(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()]
assert n % k == 0
import math

def abc(k, censor):
	a = 10 ** k - 1
	b = censor * 10 ** (k - 1) + 10 ** (k - 1) - 1
	if censor == 0:
		c = 0
	else:
		c = (censor - 1) * 10 ** (k - 1) + 10 ** (k - 1) - 1
	return (a, b, c)

def numDiv(n, div):
	return int(n / div)
t = 1
mod = int(1000000000.0) + 7
for i in range(len(B)):
	(a, b, c) = abc(k, B[i])
	aa = numDiv(a, A[i])
	bb = numDiv(b, A[i])
	cc = numDiv(c, A[i])
	if B[i] != 0:
		cc += 1
	tt = aa - bb + cc
	t = t * tt % mod
print(t)


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)
	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


(n, k) = 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
	sum1 = sum1 % M
print(sum1 % (10 ** 9 + 7))


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)


def get_arr(Len):
	buff = input().split()
	a = []
	for i in range(Len):
		a.append(int(buff[i]))
	return a
base = int(1000000000.0 + 7)
buff = input().split()
n = int(buff[0])
k = int(buff[1])
a = get_arr(n // k)
b = get_arr(n // k)
c = []
for i in range(n // k):
	ans = 0
	if b[i] != 0:
		ans += (pow(10, k) - 1) // a[i]
		ans -= (b[i] * pow(10, k - 1) + pow(10, k - 1) - 1) // a[i]
		ans += ((b[i] - 1) * pow(10, k - 1) + pow(10, k - 1) - 1) // a[i]
		ans += 1
	else:
		ans = (pow(10, k) - 1) // a[i]
		ans -= (pow(10, k - 1) - 1) // a[i]
	c.append(ans % base)
ans = 1
for i in range(n // k):
	ans *= c[i]
	ans %= base
print(ans)


(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):
	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)


import math

def func(a, b, k):
	global highest
	global base
	start = b * base
	finish = start + base - 1
	lower = math.ceil(start / a)
	upper = math.floor(finish / a)
	fauls = upper - lower + 1
	ans = int(highest / a) + 1 - fauls
	return ans
inf = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(n, k) = (inf[0], inf[1])
ans = [None] * int(n / k)
highest = 10 ** k - 1
base = 10 ** (k - 1)
w = 1
mod = 10 ** 9 + 7
for i in range(int(n / k)):
	w = w % mod * (func(a[i], b[i], k) % mod) % mod
w = w % mod
print(w)


R = lambda : map(int, input().split())
(n, k) = R()
t = 1
mod = 10 ** 9 + 7

def gn(x, p):
	if x < 0:
		return 0
	return x // p + 1

def solve(a, b, k):
	if k == 1:
		return 9 // a if b % a == 0 else 9 // a + 1
	m = b * pow(10, k - 1, a) % a
	w = 10 ** (k - 1) - 1 + m
	r = gn(10 ** k - 1, a) - (gn(w, a) - gn(m - 1, a))
	return r
a = list(R())
b = list(R())
for i in range(len(a)):
	t *= solve(a[i], b[i], k)
	t %= mod
print(t % mod)