#include using namespace std; const int64_t mod = 1000000007; vector> mul(vector>& x, vector>& y){ vector> z(3, vector(3, 0)); for(int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) for(int k = 0; k < 3; ++k) z[i][j] = (z[i][j] + 1LL * x[i][k] * y[k][j] + mod) % mod; return z; } signed main(){ long long n; long long a, b, c; scanf("%lld%lld%lld%lld", &n, &a, &b, &c); --n; vector>> ar(63, vector>(3, vector(3))); ar[0] = { {1, 0, -1}, {-1, 1, 0}, {0, -1, 1}, }; for(int k = 0; k < 62; ++k) ar[k + 1] = mul(ar[k], ar[k]); vector> v(3, vector(3, 0)); v[0][0] = v[1][1] = v[2][2] = 1; for(int k = 0; k < 63; ++k) if(n & (1uLL << k)) v = mul(v, ar[k]); long long na = (a * v[0][0] + b * v[1][0] + c * v[2][0]) % mod; long long nb = (a * v[0][1] + b * v[1][1] + c * v[2][1]) % mod; long long nc = (a * v[0][2] + b * v[1][2] + c * v[2][2]) % mod; printf("%lld %lld %lld\n", na, nb, nc); }