#include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i = a; i < b ; i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(void){
	int mery[8]={1,2,1,2,1,4,1,4};
	
	vector<int> p(8),c(mery,mery+8);
	
	while(cin>>p[0]){
		loop(i,1,8)cin>>p[i];
		int max = -1;
		vector<int> ans,t(8);
		rep(i,8){
			int s=0;
			rep(j,8){
				s+=p[j]>c[(i+j)%8]?c[(i+j)%8]:p[j];
				t[j]=c[(i+j)%8];
			}
			if(max<s || max ==s && t<ans){
				ans = t;
				max = s;
			}
		}
		
			cout<<ans[0];
			loop(i,1,8)cout<<" "<<ans[i];
			cout<<endl;
	}
}