M_N, K, A = [input() for _ in range(3)] M_N_int = [int(s) for s in M_N.split()] m = M_N_int.pop(0) n = M_N_int.pop(0) k_sp = [int(k) for k in K.split()] a1_int = [int(s) for s in A.split()] a = [a1_int] n_n = [i for i in range(n+1)] k_kai = 0 p = 1009 amari = '' def make_list(s, a): for _ in range(s-1): a.append([0]) def list_00(s, t): for i in range(1, s): for _ in range(t-1): a[i].append(0) def make_k(k): global k_kai for j in range(m+1): k_kai += k_sp[j]*p**j return k_kai def make_a(n, n_n, a): for i in range(1, k_kai): for p in range(len(a[0])+1): if n_n is not None and len(n_n)>0: for j in n_n: a[i][p] += a[i-1][j]*a[0][n-j] n_n.pop(-1) n -= 1 if n_n == []: n_n = [i for i in range(n+1)] n = len(a[0])-1 a[i].reverse() def make_kai(k_kai, p): global amari for i in range(len(a1_int)): amari += str(a[k_kai-1][i]%p) if i != len(a1_int)-1: amari += ' ' print(amari) make_k(k_sp) make_list(k_kai, a) list_00(k_kai, len(a1_int)) make_a(n, n_n, a) make_kai(k_kai,p)