#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int A[16] = {4,1,4,1,2,1,2,1,4,1,4,1,2,1,2,1};
string B = "4141212141412121";
int s2i(string s){
	return atoi(s.c_str());
}
int main(){
	vector <int> C;
	int i,j, x[8] = {},s,m,p,tmp;
	for(i=0;i<8;i++)C.push_back(s2i(B.substr(i,8)));
	while(cin>>x[0]){
		m=x[0];
		for(i=1;i<8;i++){
			cin>>x[i];
			m+=x[i];
		}
		for(i=0;i<8;i++){
			s=0;
			for(j=0;j<8;j++){
				tmp=x[j]-A[i+j];
				s+=(tmp>0?tmp:0);
			}
			if(s<m){
				m=s;
				p=i;
			}
			else if(m==s&&C[i]<C[p])p=i;
		}
		for (i=0;i<8;i++)cout<<B[p+i]<<" ";
		cout<<endl;
	}
}