#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	vector<int> C(8),J({1,2,1,2,1,4,1,4});
	while(cin>>C[0]){
		REP(i,7) cin>>C[i+1];
		int minV=0,minC=1<<24;
		REP(i,8){
			int sum = 0;
			REP(j,8){
				sum += max(0,C[j]-J[j]);
			}
			if(sum<minC){
				minC = sum;
				int V=0;
				REP(j,8){
					V *= 10;
					V += J[j];
				}
				minV = V;
			}
			else if(sum==minC){
				int V=0;
				REP(j,8){
					V *= 10;
					V += J[j];
				}
				if(V<minV){
					minV = V;
				}
			}
			rotate(J.begin(),J.begin()+1,J.end());
		}
		REP(i,8){
			C[i] = minV%10;
			minV /= 10;
		}
		reverse(ALL(C));
		REP(i,7) cout << C[i] << ' ';
		out(C[7]);
	}
	
	return 0;
}
