#include <iostream>
using namespace std;
int B[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 d[8];
int cal(int num){
	int TMP=0;
	for(int i=0;i<8;i++){
		if(d[i]>B[num][i]){
			TMP+=(d[i]-B[num][i]);
		}
	}
	return TMP;
}
int main(){
	int tmp,f;
	while(cin>>d[0]){
		for(int i=1;i<8;i++)cin>>d[i];
		f=1;
		tmp=cal(0);
		for(int i=1;i<8;i++)if(tmp>cal(i))tmp=cal(i);
		for(int i=0;f;i++){
			if(tmp==cal(i)){
				for(int j=0;j<8;j++){
					if(j<7)cout<<B[i][j]<<" ";
					else cout<<B[i][j]<<endl;
				}
				f=0;
			}
		}
		
		
	}
	return 0;
}
