# -*- coding: utf-8 -*- # 想定解(3) # 掛け合わせる def mult(V,V2,A): l = len(V) R=[0] * (l*2) for i in range(l): for j in range(l): R[i+j] += V[i]*V2[j] % mo for i in range(l,l*2): for j in range(l): R[j] += A[i][j]*R[i] for j in range(l): R[j] %= mo return R[0:l] # 1つ進める def inc(V,A): l = len(V) R=[0] * l for i in range(l-1): R[i+1]=V[i] for i in range(l): R[i] += A[l][i] * V[l-1] for i in range(l): R[i]%=mo return R N,K = map(int, raw_input().strip().split()) F = map(int, raw_input().strip().split()) F.insert(0,0) mo = 1000000007 S = [0] for i in range(1,N+1): S.append((S[i-1]+F[i]) % mo) if N > 50: # こちらは想定解(1)と同じです for i in range(N+1,K+1): F.append((S[i-1]-S[i-N-1]) % mo) S.append((S[i-1]+F[i]) % mo) print "%d %d" % (F[i], S[i]) print "%d %d" % (F[K], S[K]) else: # 通称きたまさ法 A=[[0 for i in range(N+1)] for j in range(2*N+3)] # (0-indexで)最初のN+1項を指定 for i in range(0,N+1): A[i][i]=1 A[N+1][N] = 2 A[N+1][0] = mo-1 # N+2~2N項まで愚直に計算 for i in range(0,N+1): for j in range(N+2,2*N+3): A[j][i] = (2*A[j-1][i] - A[j-(N+1)][i])%mo R=[0]*(N+1) R[0]=1 # Vは1個漸化式を進める V=inc(R,A) # S(K-1)を求める K -= 1 while K>0: if K%2 == 1: R=mult(R,V,A) V=mult(V,V,A) K /= 2 Skm = Sk = 0 for j in range(0,N+1): Skm += R[j]*S[j] # 1つ進めてS(K)を求める R=inc(R,A) for j in range(0,N+1): Sk += R[j]*S[j] print (Sk-Skm)%mo,Sk%mo