#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) __typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } template struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) {} ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; } ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } }; typedef ModInt<1000000007> mint; struct Matrix { typedef mint Num; static const int MaxN = 31; int hei, wid; Num v[MaxN][MaxN]; Matrix() {} Matrix(int n, int m): hei(n), wid(m) { mset(v, 0); } inline int height() const { return hei; } inline int width() const { return wid; } inline Num& at(int i, int j) { return v[i][j]; } inline const Num& at(int i, int j) const { return v[i][j]; } static Matrix identity(int n) { Matrix A(n, n); rep(i, n) A.at(i, i) = 1; return A; } inline static Matrix identity(const Matrix& A) { return identity(A.height()); } Matrix& operator*=(const Matrix& B) { int n = height(), m = B.width(), p = B.height(); assert(p == width()); const unsigned (*b)[MaxN] = reinterpret_cast(B.v); Num w[MaxN][MaxN]; unsigned long long pp = (1ULL << 32) % mint::Mod; rep(i, n) { const unsigned *ai = reinterpret_cast(v[i]); rep(j, m) { unsigned x0 = 0; unsigned long long x1 = 0; rep(k, p) { unsigned long long y = (unsigned long long)ai[k] * b[k][j]; unsigned long long t = x0 + y; x1 += t >> 32; x0 = t & 0xffffffff; } w[i][j].x = (x0 + x1 % mint::Mod * pp) % mint::Mod; } } memcpy(v, w, sizeof(v)); return *this; } }; Matrix operator^(const Matrix& t, ll k) { Matrix A = t, B = Matrix::identity(t); while(k) { if(k & 1) B *= A; A *= A; k >>= 1; } return B; } int main() { int N; ll K; while(~scanf("%d%lld", &N, &K)) { vector A(N); for(int i = 0; i < N; ++ i) scanf("%d", &A[i]); mint ansF, ansS; if(N > 30) { vector dp((int)K+1), dpsum((int)K+1); rer(k, 1, (int)K) { dp[k] = k <= N ? A[k - 1] : dpsum[k - 1] - dpsum[k - N - 1]; dpsum[k] = dpsum[k - 1] + dp[k]; } ansF = dp[(int)K], ansS = dpsum[(int)K]; } else { Matrix P(N+1, N+1); rep(i, N-1) P.at(i + 1, i) = 1; rep(i, N) P.at(i, N - 1) = 1; P.at(0, N) = 1; P.at(N, N) = 1; Matrix b(1, N+1); rep(i, N) b.at(0, i) = A[i]; b *= P ^ (K-1); ansF = b.at(0, 0); ansS = b.at(0, N) + ansF; } printf("%d %d\n", ansF.get(), ansS.get()); } return 0; }