#include <iostream>

using namespace std;

string str[8] = {
	"41412121",
	"41212141",
	"21414121",
	"21214141",
	"14141212",
	"14121214",
	"12141412",
	"12121414"
};

int main(){
	
	int p[8], c[8], ans, min, sum;
	
	while(true){
		
		cin >> p[0];
		
		if(cin.eof()){
			break;
		}
		
		cin >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7];
		
		min = 1 << 30;
		
		for(int i = 0; i < 8; i++){
			sum = 0;
			for(int j = 0; j < 8; j++){
				if(p[j] - (str[i][j] - '0') < 0){
					sum += 0;
				}else{
					sum += (p[j] - (str[i][j] - '0'));
				}
			}
			//cout << sum << endl;
			if(sum <= min){
				min = sum;
				ans = i;
			}
		}
		
		for(int i = 0; i < 7; i++){
			cout << str[ans][i] << " ";
		}
		
		cout << str[ans][7] << endl;
	}
	return 0;
}