#include using namespace std; using ll = int64_t; #define rep(i,n) for (int i=0;i<(int)(n);i++) void mv(int x,vector &v,vector &dd){ int cmv=v.at((x+1)%4)-dd.at((x+1)%4); if(dd.at(x)>cmv){ dd.at((x+1)%4)=v.at((x+1)%4); dd.at(x)-=cmv; }else{ dd.at((x+1)%4)+=dd.at(x); dd.at(x)=0; } } int main(){ vector v(4); vector dd(4,0); rep(i,4) cin>>v.at(i); ll n; cin>>n; dd.at(0)=v.at(0); vector,int>> st(4); st.at(3)[dd]=-1; rep(i,n){ mv(i%4,v,dd); if(st.at(i%4).count(dd)) i+=(i-st.at(i%4).at(dd))*((n-i-1)/(i-st.at(i%4).at(dd))); st.at(i%4)[dd]=i; } rep(i,4) { cout<