A company needs random numbers for its operation. $N$ random numbers have been generated using $N$ numbers as seeds and the following recurrence formula:

$\begin{aligned}F(K)=&\left(C(1)\times F(K-1)+C(2)\times F(K-2)+\cdots+C(N-1)\times F(K-N+1)+C(N)\times F(K-N)\right)\text{\%}\left(10^9+7\right)\end{aligned}$

The numbers used as seeds are $F(N-1),F(N-2),...,F(1),F(0)$. $F(K)$ is the $K^{\mbox{th}}$ term of the recurrence.

Due to a failure on the servers, the company lost its seed numbers. Now they just have the recurrence formula and the previously generated $N$ random numbers.

The company wants to recover the numbers used as seeds, so they have hired you for doing this task.

Input Format

The first line contains two space-separated integers, $N$ and $\mbox{K}$, respectively. 

The second line contains the space-separated integers describing $F(K),F(K-1),...,F(K-N+2),F(K-N+1)$ (all these numbers are non-negative integers $<10^9$). 

The third line contains the space-separated coefficients of the recurrence formula, $C(1),C(2),...,C(N-1),C(N)$. All of these coefficients are positive integers $<10^9$.

Constraints

$1\leq N\leq50$
$1\leq K\leq10^9$
$0\leq K-N+1$

Output Format

The output must be one line containing the space-separated seeds of the random numbers - $F(N-1),F(N-2),...,F(1),F(0)$.

Sample Input
2 6
13 8
1 1

Sample Output
1 1 

Explanation

This is the classic Fibonacci recurrence. We have the $6^{th}$ and $5^{th}$ terms, and, of course, the seeds are the numbers $1$ and $1$.

Difficulty: HARD
Tags: Dynamic programming
Skill types: Dynamic programming

Starter code:

Solutions:
MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


def expmod(exp, pow, mod):
	if pow <= 1:
		return exp if pow else 1
	return (exp if pow % 2 else 1) * expmod(exp * exp % mod, pow // 2, mod) % mod

def inversemod(base, mod):
	return expmod(base, mod - 2, mod)

def forwardMatrix(coefficients):
	N = len(coefficients)
	mat = [coefficients][:] + [[0] * i + [1] + [0] * (N - i - 1) for i in range(N - 1)]
	return mat

def inverseMatrix(coefficients, mod):
	N = len(coefficients)
	mat = [[0] * i + [1] + [0] * (N - i - 1) for i in range(1, N)]
	last_C_inverse = inversemod(coefficients[-1], mod)
	last_row = [last_C_inverse] + [-coefficients[c] * last_C_inverse % mod for c in range(N - 1)]
	mat.append(last_row)
	return mat

def matrixMultMod(mat1, mat2, mod):
	(num_rows, num_columns) = (len(mat1), len(mat2[0]))
	L = len(mat2)
	assert len(mat1[0]) == len(mat2)
	return [[sum((mat1[row][i] * mat2[i][col] for i in range(L))) % mod for col in range(num_columns)] for row in range(num_rows)]

def identityMatrix(N):
	return [[0] * i + [1] + [0] * (N - i - 1) for i in range(N)]

def expMatrixMod(exp, pow, mod):
	if pow <= 1:
		return exp if pow else identityMatrix(len(exp))
	rest = expMatrixMod(matrixMultMod(exp, exp, mod), pow // 2, mod)
	if pow % 2:
		return matrixMultMod(exp, rest, mod)
	else:
		return rest

def verticalVector(horizontalVector):
	return [[entry] for entry in horizontalVector]

def horizontalVector(verticalVector):
	return [row[0] for row in verticalVector]

def recurrenceSeedsMod(values, K, coefficients, mod):
	inverse = inverseMatrix(coefficients, mod)
	full_inverse = expMatrixMod(inverse, K - len(values) + 1, mod)
	verticalValues = matrixMultMod(full_inverse, verticalVector(values), mod)
	return horizontalVector(verticalValues)

def main():
	(N, K) = map(int, input().split())
	values = [int(entry) for entry in input().split()]
	coefficients = [int(entry) for entry in input().split()]
	MOD = 10 ** 9 + 7
	seeds = recurrenceSeedsMod(values, K, coefficients, MOD)
	print(' '.join(map(str, seeds)))
main()


from copy import deepcopy

def mx_mul(A, B, mod):
	return [[sum((a * b for (a, b) in zip(row, col))) % mod for col in zip(*B)] for row in A]

def mx_pow(M, p, mod):
	if p == 0:
		return [[0] * i + [1] + [0] * (len(M) - i - 1) for i in range(len(M))]
	if p == 1:
		return M
	if p % 2 == 0:
		Mp2 = mx_pow(M, p // 2, mod)
		return mx_mul(Mp2, Mp2, mod)
	return mx_mul(M, mx_pow(M, p - 1, mod), mod)

def invert_mod(M, mod):

	def get_identity(size):
		res = [[0] * size for _ in range(size)]
		for i in range(size):
			res[i][i] = 1
		return res

	def check_for_all_zeros(M, y, x):
		non_zeros = []
		first_non_zero = -1
		for m in range(y, len(M)):
			non_zero = M[m][x] != 0
			non_zeros.append(non_zero)
			if first_non_zero == -1 and non_zero:
				first_non_zero = m
		zero_sum = sum(non_zeros)
		return (zero_sum, first_non_zero)

	def mod_inverse(a, mod):
		(t, nt) = (0, 1)
		(r, nr) = (mod, a)
		while nr != 0:
			quotient = r // nr
			(t, nt) = (nt, t - quotient * nt)
			(r, nr) = (nr, r - quotient * nr)
		if r > 1:
			raise Exception('a is not invertible')
		if t < 0:
			t += mod
		return t
	M = deepcopy(M)
	(Y, X) = (len(M), len(M[0]))
	idm = get_identity(Y)
	for y in range(Y):
		M[y] += idm[y]
	y = 0
	for x in range(X):
		(zero_sum, first_non_zero) = check_for_all_zeros(M, y, x)
		if zero_sum == 0:
			if x == X:
				return M
			raise Exception('Matrix is singular.')
		if first_non_zero != y:
			(M[y], M[first_non_zero]) = (M[first_non_zero], M[y])
		modinv = mod_inverse(M[y][x], mod)
		M[y] = [v * modinv % mod for v in M[y]]
		for q in range(Y):
			if q == y:
				continue
			scaled_row = [M[q][x] * v % mod for v in M[y]]
			M[q] = [(M[q][w] - scaled_row[w]) % mod for w in range(len(scaled_row))]
		if y == Y or x == X:
			break
		y += 1
	for i in range(Y):
		M[i] = M[i][X:]
	return M
mod = 10 ** 9 + 7
(N, K) = map(int, input().rstrip().split())
F = list(map(int, input().rstrip().split()))
C = list(map(int, input().rstrip().split()))
assert len(F) == len(C)
A = [C if i == 0 else [0] * (i - 1) + [1] + [0] * (N - i) for i in range(N)]
V = [[i] for i in F]
p = mx_pow(A, K - N + 1, mod)
pi = invert_mod(p, mod)
res = mx_mul(pi, V, mod)
print([' '.join(map(str, col)) for col in zip(*res)][0])


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


from itertools import product
MOD = int(10 ** 9 + 7)

def euclid(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(gcd, x, y) = euclid(b % a, a)
		return (gcd, y - b // a * x, x)

def mod_inv(b, m):
	(gcd, x, _) = euclid(b, m)
	return x % m if gcd == 1 else -1

def mat_mul(A, B):
	N = len(A)
	C = [[0] * N for _ in range(N)]
	for (i, j) in product(range(N), range(N)):
		for k in range(N):
			C[i][j] += A[i][k] * B[k][j]
		C[i][j] = C[i][j] % MOD
	return C

def inverse(C):
	N = len(C)
	M = [[0] * (i + 1) + [C[-1]] + [0] * (N - i - 2) for i in range(N - 1)]
	M.append([1] + [-x for x in C[:-1]])
	return M

def mat_pow(M, p):
	N = len(M)
	A = [[0] * i + [1] + [0] * (N - i - 1) for i in range(N)]
	while p:
		if p % 2:
			A = mat_mul(A, M)
		p >>= 1
		if p:
			M = mat_mul(M, M)
	return A

def base_pow(b, p):
	x = 1
	while p:
		if p % 2:
			x = x * b % MOD
		p >>= 1
		if p:
			b = b ** 2 % MOD
	return x

def solve(N, K, F, C):
	B = inverse(C)
	p = K - N + 1
	M = mat_pow(B, p)
	mi = mod_inv(base_pow(C[-1], p), MOD)
	out = []
	for i in range(N):
		x = 0
		for j in range(N):
			x += M[i][j] * F[j]
		out.append(x * mi % MOD)
	return out
(N, K) = map(int, input().split())
F = list(map(int, input().split()))
C = list(map(int, input().split()))
sol = solve(N, K, F, C)
print(' '.join(map(str, sol)))


big = 10 ** 9 + 7

def multMatrix(A, B):
	res = [[0] * k for _ in range(k)]
	mult = lambda x, y: x * y
	for (j, col) in enumerate(zip(*B)):
		for (i, row) in enumerate(A):
			res[i][j] = sum(map(mult, row, col)) % big
	return res

def squareMatrix(A):
	res = [[0] * k for _ in range(k)]
	mult = lambda x, y: x * y
	for (j, col) in enumerate(zip(*A)):
		for (i, row) in enumerate(A):
			res[i][j] = sum(map(mult, row, col)) % big
	return res

def powMatrix(A, p):
	if p == 1:
		return A
	X = powMatrix(A, p // 2)
	if p & 1:
		return multMatrix(A, squareMatrix(X))
	else:
		return squareMatrix(X)
(k, n) = [int(x) for x in input().split(' ')]
F = [int(x) for x in input().split(' ')]
C = [int(x) for x in input().split(' ')]
ck = C[-1]
M = [[0] * k for _ in range(k)]
for i in range(k - 1):
	M[i][i + 1] = ck
M[-1] = [1] + [-x for x in C[:-1]]
if n - k + 1 == 0:
	print(' '.join((str(x) for x in F)))
	exit()
M = powMatrix(M, n - k + 1)
ck_inv = pow(ck, big - 2, big)
F0 = [sum(map(lambda x, y: x * y, row, F)) * pow(ck_inv, n - k + 1, big) % big for row in M]
print(' '.join((str(x) for x in F0)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


import math
import os
import random
import re
import sys
MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


import math
import os
import random
import re
import sys
MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


import math
import os
import random
import re
import sys
MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


import math
import os
import random
import re
import sys
MOD = 1000000007

def generali(a, b):
	if b > a:
		return generali(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generali(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generali(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
ak = list(map(int, input().split()))
ac = list(map(int, input().split()))
l = [[x] for x in ak]
m = [[0 for _ in range(n)] for _ in range(n)]
m[0] = list(ac)
for i in range(1, n):
	m[i][i - 1] = 1
inv = inversematrix1(m, MOD)
inv = [[int(x) for x in y] for y in inv]
res = matpow(inv, k - n + 1)
res = mult(res, l)
print(' '.join(map(lambda x: str(x[0]), res)))


ZOP = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % ZOP
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, ZOP)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


JOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % JOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, JOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))


MOD = 1000000007

def generalizedEuclidianAlgorithm(a, b):
	if b > a:
		return generalizedEuclidianAlgorithm(b, a)
	elif b == 0:
		return (1, 0)
	else:
		(x, y) = generalizedEuclidianAlgorithm(b, a % b)
		return (y, x - a // b * y)

def inversemodp(a, p):
	a = a % p
	if a == 0:
		return 0
	(x, y) = generalizedEuclidianAlgorithm(p, a % p)
	return y % p

def identitymatrix(n):
	return [[int(x == y) for x in range(0, n)] for y in range(0, n)]

def multiply_vector_scalar(vector, scalar, q):
	kq = []
	for i in range(0, len(vector)):
		kq.append(vector[i] * scalar % q)
	return kq

def minus_vector_scalar1(vector1, scalar, vector2, q):
	kq = []
	for i in range(0, len(vector1)):
		kq.append((vector1[i] - scalar * vector2[i]) % q)
	return kq

def inversematrix1(matrix, q):
	n = len(matrix)
	A = []
	for j in range(0, n):
		temp = []
		for i in range(0, n):
			temp.append(matrix[j][i])
		A.append(temp)
	Ainv = identitymatrix(n)
	for i in range(0, n):
		factor = inversemodp(A[i][i], q)
		A[i] = multiply_vector_scalar(A[i], factor, q)
		Ainv[i] = multiply_vector_scalar(Ainv[i], factor, q)
		for j in range(0, n):
			if i != j:
				factor = A[j][i]
				A[j] = minus_vector_scalar1(A[j], factor, A[i], q)
				Ainv[j] = minus_vector_scalar1(Ainv[j], factor, Ainv[i], q)
	return Ainv

def mult(x, y):
	c = [[0 for _ in range(len(y[0]))] for _ in range(len(x))]
	for i in range(len(x)):
		for j in range(len(y[0])):
			for k in range(len(x)):
				c[i][j] += x[i][k] * y[k][j]
				c[i][j] = c[i][j] % MOD
	return c

def matpow(b, p):
	if p == 0:
		return identitymatrix(n)
	if p == 1:
		return b
	if p % 2 == 1:
		return mult(b, matpow(b, p - 1))
	ret = matpow(b, p // 2)
	return mult(ret, ret)
(n, k) = map(int, input().split())
arrk = list(map(int, input().split()))
arrc = list(map(int, input().split()))
left = [[x] for x in arrk]
middle = [[0 for _ in range(n)] for _ in range(n)]
middle[0] = list(arrc)
for i in range(1, n):
	middle[i][i - 1] = 1
inv = inversematrix1(middle, MOD)
inv = [[int(x) for x in y] for y in inv]
ans = matpow(inv, k - n + 1)
ans = mult(ans, left)
print(' '.join(map(lambda x: str(x[0]), ans)))