//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 922337203685477580LL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} long long modinv(long long a, long long mod) { long long b = mod, u = 1, v = 0; while (b) { long long t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } // matrix template struct Matrix { vector > val; Matrix(int n, int m, long long x = 0) : val(n, vector(m, x)) {} void init(int n, int m, long long x = 0) {val.assign(n, vector(m, x));} size_t size() const {return val.size();} inline vector& operator [] (int i) {return val[i];} }; template ostream& operator << (ostream& s, Matrix A) { s << endl; for (int i = 0; i < A.size(); ++i) { for (int j = 0; j < A[i].size(); ++j) { s << A[i][j] << ", "; } s << endl; } return s; } template Matrix operator * (Matrix A, Matrix B) { Matrix R(A.size(), B[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < B[0].size(); ++j) for (int k = 0; k < B.size(); ++k) R[i][j] = (R[i][j] + A[i][k] * B[k][j] % MOD) % MOD; return R; } template Matrix pow(Matrix A, long long n) { Matrix R(A.size(), A.size()); for (int i = 0; i < A.size(); ++i) R[i][i] = 1; while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; } return R; } //head ll n; int a, b, c; Matrix<1000000007> mat(3, 3); int main() { ios::sync_with_stdio(false); cin.tie(0); mat[0][0] = mat[1][1] = mat[2][2] = 1; mat[0][1] = mat[1][2] = mat[2][0] = 1000000006; cin >> n >> a >> b >> c; mat = pow(mat, n-1); //cout << mat << endl; rep(i, 3) { cout << (mat[i][0]*a+mat[i][1]*b+mat[i][2]*c)%1000000007 << (i == 2?'\n':' '); } }