#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mp make_pair #define pb push_back #define all(x) (x).begin(),(x).end() #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vb; typedef vector vi; typedef vector vvb; typedef vector vvi; typedef pair pii; const int INF=1<<29; const double EPS=1e-9; const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; const long long int mod = 1000000007ll; vvi mul_(vvi &A, vvi &B) { vector > C(A.size(), vector(B[0].size(), 0)); for (int i = 0; i < A.size(); ++i) { for (int k = 0; k < B.size(); ++k) { for (int j = 0; j < B[0].size(); ++j) { C[i][j] = ((ll)A[i][k] * B[k][j] + C[i][j] + mod * mod) % mod; } } } vvi D(A.size(), vi(B[0].size(), 0)); for (int i = 0; i < A.size(); ++i) { for (int j = 0; j < B[0].size(); ++j) { D[i][j] = C[i][j] % mod; } } return D; } vvi mul(vvi A, long long int n) { vvi B(A.size(), vi(A[0].size(), 0)); for (int i = 0; i < B.size(); ++i) { B[i][i] = 1; } while(n > 0) { if (n & 1) { B = mul_(B, A); } A = mul_(A, A); n >>= 1; } return B; } int main(int argc, char const *argv[]) { long long int N, K; cin >> N >> K; if (N <= 10000 && K <= 1000000) { std::vector fib(K); int sum = 0; for (int i = 0; i < N; ++i) { int temp; cin >> temp; sum += temp; fib[i] = temp; } for (int i = N; i < K; ++i) { fib[i] = sum; sum = sum + mod - fib[i - N]; sum %= mod; sum += fib[i]; sum %= mod; } int ret = 0; for (int i = 0; i < K; ++i) { ret += fib[i]; ret %= mod; //cout << fib[i] << " "; } //cout << endl; cout << fib[K - 1] << " " << ret << endl; } else { vvi G(N + 1, vi(N + 1, 0)); G[0][0] = 2; G[0][G[0].size() - 1] = mod - 1; for (int i = 0; i < G.size() - 1; ++i) { G[i + 1][i] = 1; } G = mul(G, K - N); vi v(N + 1); int sum = 0; v[v.size() - 1] = 0; for (int i = 0; i < v.size() - 1; ++i) { int temp; cin >> temp; sum += temp; v[v.size() - i - 2] = sum; } long long int Sk = 0, Sk_ = 0; for (int i = 0; i < N; ++i) { Sk += ((ll)G[0][i] * v[i] + mod * mod) % mod; } for (int i = 0; i < N; ++i) { Sk_ += ((ll)G[1][i] * v[i] + mod * mod) % mod; } cout << (Sk - Sk_ + mod) % mod << " " << Sk % mod << endl; } return 0; }