#include<iostream>
#include<climits>
using namespace std;
int main(){
	int s[8],d[]={4,1,4,1,2,1,2,1,4,1,4,1,2,1,2};
	int best,min,sum;
	while(cin>>s[0]>>s[1]>>s[2]>>s[3]>>s[4]>>s[5]>>s[6]>>s[7]){
		min=INT_MAX;
		for(int i=0;i<8;i++){
			sum=0;
			for(int j=0;j<8;j++){
				if(s[j]-d[i+j]<0)
					;
				else{
					sum+=(s[j]-d[i+j]);
				}

			}

			if(min>sum){
				min=sum;
				best=i;
			}
		}
		for(int i=best;i<best+7;i++)
		cout<<d[i]<<' ';
		cout<<d[best+7]<<endl;

	}
	return 0;
}
	 