#include "bits/stdc++.h"
using namespace std;
int data_ary[8][8]={{1,2,1,2,1,4,1,4},{1,2,1,4,1,4,1,2},{1,4,1,2,1,2,1,4},
		{1,4,1,4,1,2,1,2},{2,1,2,1,4,1,4,1},{2,1,4,1,4,1,2,1},{4,1,2,1,2,1,4,1},{4,1,4,1,2,1,2,1}};
int sum,ans;
int all_sum,result=10000000;
int data[8]={0};
int main(){
	while(~scanf("%d %d %d %d %d %d %d %d",
			&data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7])){
		ans=0;
		result=10000000;
		for (int i = 0; i < 8; ++i) {
			sum=0;
			all_sum=0;
			for (int j = 0; j < 8; ++j) {
			sum=data[j]-data_ary[i][j];
			if(sum<0){sum=0;}
			else{all_sum=all_sum+sum;}
		}
		if(all_sum<result){
			result=all_sum;
			ans=i;
		}
	}
    for (int i = 0; i < 8; ++i) {
		if(i){cout<<" "<<data_ary[ans][i];}
		else{cout<<data_ary[ans][i];}
	}
    cout<<endl;
	}
}