#ifdef _DEBUG #ifdef _SORAIE #define _GLIBCXX_DEBUG #endif #endif #include #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; //-------------------------------------------------------------------- #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define overload4(_1,_2,_3,_4,name,...) name #define rep1(n) for(ll _ThiS_WoNt_Be_usEd=0;_ThiS_WoNt_Be_usEd<(ll)n;++_ThiS_WoNt_Be_usEd) #define rep2(i,n) for(ll i=0;i<(ll)n;++i) #define rep3(i,a,b) for(ll i=(ll)a;i<(ll)b;++i) #define rep4(i,a,b,c) for(ll i=(ll)a;i<(ll)b;i+=(ll)c) #define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__) #ifdef _DEBUG #define pass(...) __VA_ARGS__ ; #define debug1(a) cerr<<(#a)<<": "<<(a)<<"\n" #define debug2(a,b) cerr<<(#a)<<": "<<(a)<<", "<<(#b)<<": "<<(b)<<"\n" #define debug3(a,b,c) cerr<<(#a)<<": "<<(a)<<", "<<(#b)<<": "<<(b)<<", "<<(#c)<<": "<<(c)<<"\n" #define debug4(a,b,c,d) cerr<<(#a)<<": "<<(a)<<", "<<(#b)<<": "<<(b)<<", "<<(#c)<<": "<<(c)<<", "<<(#d)<<": "<<(d)<<"\n" /* #define debug1(a) cout<<#a<<": "<ostream& operator<<(ostream& os,const pair& pp) {return os << "{" << pp.first << "," << pp.second << "}";} templateostream& operator<<(ostream& os,const vector& VV) {if(VV.empty())return os<<"[]";os<<"[";rep(i,VV.size())os<ostream& operator<<(ostream& os,const set& SS) {if(SS.empty())return os<<"[]";os<<"[";auto ii=SS.begin();for(;ii!=SS.end();ii++)os<<*ii<<(ii==prev(SS.end())?"]":",");return os;} templateostream& operator<<(ostream& os,const map& MM) {if(MM.empty())return os<<"[]";os<<"[";auto ii=MM.begin();for(;ii!=MM.end();ii++)os<<"{"<first<<":"<second<<"}"<<(ii==prev(MM.end())?"]":",");return os;} constexpr int inf = 1 << 30; constexpr ll INF = 1LL << 61; constexpr ld pi = 3.14159265358; constexpr ll mod1 = 1000000007LL; constexpr ll mod2 = 998244353LL; using pll = pair; using pli = pair; using pii = pair; template inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; } template inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; } ll modpow(ll n,ll m,ll MOD){ if(m == 0)return 1; if(m < 0)return 0; ll res = 1; n %= MOD; while(m){ if(m & 1)res = (res * n) % MOD; m >>= 1; n *= n; n %= MOD; } return res; } ll mypow(ll n,ll m){ if(m == 0)return 1; if(m < 0)return -1; ll res = 1; while(m){ if(m & 1)res = (res * n); m >>= 1; n *= n; } return res; } inline bool isp(ll n){ bool res = true; if(n == 1 || n == 0)return false; else{ for(ll i = 2;i * i <= n;i++){ if(n % i == 0){ res = false; break; } } return res; } } inline bool Yes(bool b = 1){cout << (b ? "Yes\n":"No\n");return b;} inline bool YES(bool b = 1){cout << (b ? "YES\n":"NO\n");return b;} map primefactor(ll n){ map ma; if(n <= 1)return ma; ll m = n; for(ll i = 2;i * i <= n;i++){ while(m % i == 0){ ma[i]++; m /= i; } } if(m != 1)ma[m]++; return ma; } vector divisor(ll n,bool sorted = true,bool samein = false){ vector res; for(ll i = 1;i * i <= n;i++){ if(n % i == 0){ res.push_back(i); if(i * i != n || samein)res.push_back(n / i); } } if(sorted)sort(all(res)); return res; } ll __lcm(ll a,ll b){return a / __gcd(a,b) * b;} templateT sum(const vector &V){T r=0;for(auto x:V)r+=x;return r;} templateT sum(const initializer_list &V){T r=0;for(auto x:V)r+=x;return r;} #if __has_include("atcoder/all") #include using namespace atcoder; template OS& operator<<(OS& os,const static_modint& self){os << self.val();return os;} #endif // #include // using lld = boost::multiprecision::number>; // #include // using lll = boost::multiprecision::cpp_int; //-------------------------------------------------------------------- template struct Matrix{ int h,w; std::vector> dat; Matrix(const std::vector>& _dat):h(_dat.size()),w(_dat[0].size()),dat(_dat){} Matrix(const int& _h,const int& _w):h(_h),w(_w),dat(std::vector>(_h,std::vector(_w))){} std::vector& operator[](int k){return dat[k];} inline constexpr Matrix &operator+=(const Matrix& a) noexcept { assert(a.h == h && a.w == w); for(int i = 0;i < h;i++){ for(int j = 0;j < w;j++){ dat[i][j] += a.dat[i][j]; } } return *this; } inline constexpr Matrix &operator*=(const Matrix& a) noexcept { assert(w == a.h); Matrix res(h,a.w); for(int i = 0;i < h;i++){ for(int j = 0;j < a.h;j++){ for(int k = 0;k < a.w;k++){ res[i][k] += dat[i][j] * a.dat[j][k]; } } } *this = res; return *this; } inline constexpr Matrix operator+(const Matrix& a) const noexcept { return Matrix(*this) += a; } inline constexpr Matrix operator*(const Matrix& a) const noexcept { return Matrix(*this) *= a; } inline constexpr Matrix pow(long long k) const noexcept { assert(h == w); Matrix res = id(h),a(*this); while(k){ if(k & 1)res *= a; a *= a; k >>= 1; } return res; } inline constexpr static Matrix id(int n){ Matrix res(n,n); for(int i = 0;i < n;i++)res.dat[i][i] = T(1); return res; } friend std::ostream &operator<<(std::ostream& os,const Matrix& a){ for(int i = 0;i < a.dat.size();i++){ os << "["; for(int j = 0;j < a.dat[i].size();j++){ os << a.dat[i][j] << (j == a.dat[i].size() - 1 ? "]" : " "); } if(i != a.dat.size() - 1)os << "\n"; } return os; } }; int main() { using mint = modint1000000007; ll N; cin >> N; ll _A,_B,_C; cin >> _A >> _B >> _C; mint A = _A,B = _B,C = _C; Matrix M(3,1),X(3,3); M[0][0] = A; M[1][0] = B; M[2][0] = C; X[0][0] = 1;X[0][1] = -1;X[0][2] = 0; X[1][0] = 0;X[1][1] = 1;X[1][2] = -1; X[2][0] = -1;X[2][1] = 0;X[2][2] = 1; // debug(M,X); debug(X * M); auto ans = X.pow(N - 1) * M; cout << ans[0][0] << " " << ans[1][0] << " " << ans[2][0] << "\n"; }