#include<iostream>
#include<algorithm>
using namespace std;
int m[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 main(){
	int c[8];
	while(cin>>c[0]){
	for(int i=1;i<8;i++)cin>>c[i];
	int best=1000000000,set;
	for(int i=0;i<8;i++){
		int cnt=0;
		for(int j=0;j<8;j++){
			cnt+=max(0,c[j]-m[i][j]);
		}
		if(cnt<best){
			best=cnt;
			set=i;
		}
	}
	for(int i=0;i<7;i++){
		cout<<m[set][i]<<" ";
	}
	cout<<m[set][7]<<endl;
	}
	return 0;
}