#include #include #include #include #include #include #include #include #include #include #include #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define mod 1000000007 typedef long long ll; using namespace std; int inputValue(){ int a; cin >> a; return a; }; template void output(T a, int precision) { if(precision > 0){ cout << setprecision(precision) << a << "\n"; } else{ cout << a << "\n"; } } vector> multi_mat(vector> a, vector> b, ll m){ vector> ret(a.size(), vector(a.size(), 0)); rep(i, a.size()){ rep(j, a.size()){ rep(k, a.size()){ ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % m; } } } return ret; } vector> pow_mat(vector> mat, ll pow, ll m){ vector> ret(mat.size(), vector(mat.size(), 0)); rep(i, mat.size()){ ret[i][i] = 1; } while (pow > 0) { if (pow & 1) { ret = multi_mat(mat, ret, m); } mat = multi_mat(mat, mat, m); pow >>= 1; } return ret; } int main() { // source code int N; // 10^4, 30 ll K; // 10^6, 10^12 cin >> N >> K; vector A(N); // 9 for (int i = 0; i < N; i++) { cin >> A[i]; } if (N > 30) { // #1 N > 30 vector S(K); // 10^6 S[0] = A[0]; repd(i, 1, N){ S[i] = (A[i] + S[i - 1]) % mod; } if (K >= N) { for (ll i = N; i < K; i++) { if (i == N) { S[i] = (2 * S[i - 1]) % mod; } else{ S[i] = (2 * S[i - 1] - S[i - (N + 1)] + mod) % mod; } } } cout << (S[K - 1] - S[K - 2] + mod) % mod << " "; cout << S[K - 1] << endl;// F(K), S(K) } else{ // #2 K large vector S(N); // 30 S[0] = A[0]; repd(i, 1, N){ S[i] = (A[i] + S[i - 1]) % mod; } if (N >= K) { cout << (S[K - 1] - S[K - 2] + mod) % mod << " "; cout << S[K - 1] << endl;// F(K), S(K) return 0; } // コンパニオン行列の作成 vector> mat(N + 1, vector(N + 1)); rep(i, N + 1){ mat[0][i] = 1; } repd(i, 1, N + 1){ mat[1][i] = 1; } repd(i, 2, N + 1){ mat[i][i - 1] = 1; } vector> ret = pow_mat(mat, K - N, mod); ll Sk = 0; ll Fk = 0; rep(i, N + 1){ if (i == 0) { Sk = (S[N - 1] * ret[0][0]) % mod; continue; } Sk = (Sk + A[N - i] * ret[0][i]) % mod; } repd(i, 1, N + 1){ Fk = (Fk + A[N - i] * ret[1][i]) % mod; } cout << Fk << " "; cout << Sk << endl; } return 0; }