#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main(){
	
	vector<int> mel;
	mel.push_back(2);
	mel.push_back(1);
	mel.push_back(2);
	mel.push_back(1);
	mel.push_back(4);
	mel.push_back(1);
	mel.push_back(4);
	mel.push_back(1);
	
	typedef pair<int,int> pii;
	vector<int> in(8);
	while(cin>>in[0]){
		reps(i,1,8)cin>>in[i];
		
		vector<pii> cand;
			
		rep(i,mel.size()){
			int dist = 0;
			rep(j,mel.size()){
				dist += max(0,in[j]-mel[j]);
			}
			
			int sum = 0;
			rep(j,mel.size()){
				sum *= 10;
				sum += mel[j];
			}
			
			cand.push_back(pii(dist,sum));
			
			mel.push_back(mel[0]);
			mel.erase(mel.begin());
		}
		
		
		rep(j,cand.size()){
			//printf("%d %d !!!!#####\n",cand[j].first,cand[j].second);
		}
		sort(cand.begin(),cand.end());
		
		rep(j,cand.size()){
			//printf("%d %d !!!!\n",cand[j].first,cand[j].second);
		}
		int p = cand[0].second;
		vector<int> hoge;
		rep(i,mel.size()){
			hoge.push_back(p%10);
			p/=10;
		}
		
		rep(i,hoge.size()){
			if(i!=0)printf(" ");
			printf("%d",hoge[hoge.size()-1-i]);
		}puts("");
	}
	
	
	
}