#include<iostream>
using namespace std;
int main(){
	int people[8];
	while(cin >>people[0]>>people[1]>>people[2]>>people[3]>>people[4]>>people[5]>>people[6]>>people[7]){
		int jenny[9] = {4,1,4,1,2,1,2,1,0},ans[8],min = 10000;
		for(int k=0; k<8; k++){
			int p = 0;
			for(int i=0; i<8; i++){if(people[i]-jenny[i]>0){p+=people[i]-jenny[i];}}
			if(p<min){
				min = p;
				for(int i=0; i<8; i++){
					ans[i] = jenny[i];
				}
			}
			else if(p == min){
				for(int i=0; i<8; i++){
					if(jenny[i]>ans[i]){break;}
					if(jenny[i]<ans[i]){
						for(int j=0; j<8; j++){
							ans[j] = jenny[j];
						}
						break;
					}
				}
			}
			jenny[8] = jenny[0];
			for(int i=0; i<8; i++){
				jenny[i] = jenny[i+1];
			}
		}
		cout <<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<" "<<ans[4]<<" "<<ans[5]<<" "<<ans[6]<<" "<<ans[7]<<endl;
	}
	return 0;
}