#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n[8], c[8];
int debug = 0;

void rotate(){
	int tmp=c[7];
	
	for(int i=7;i>=0;i--){
		c[i] = c[i-1];
	}
	c[0] = tmp;
}

int main(void){
	
	while(cin >> n[0] >> n[1] >> n[2] >> n[3] >> n[4] >> n[5] >> n[6] >> n[7]){
		int maxi=0;
		string maxistr="12121414";
		if(debug){
			for(int i=0;i<8;i++){
				cout << n[i];
			}
			cout << endl;
		}
		c[0] = 1; c[1] = 2; c[2] = 1; c[3] = 2;
		c[4] = 1; c[5] = 4; c[6] = 1; c[7] = 4;
		
		for(int i=0;i<8;i++){
			int tmp = 0;
			string tmpstring = "";
			for(int j=0;j<8;j++){
				if(c[j] > n[j]){
					tmp += n[j];
				}else{
					tmp += c[j];
				}
			}
			if(debug) cout << "tmp = " << tmp << endl;
			if(tmp < maxi){
				//do nothing
			}else{
				//make string
				for(int j=0;j<8;j++){
					tmpstring += c[j] + '0';
				}
				if(debug) cout << "tmp maxi = " << tmpstring << endl;
				if(tmp > maxi){
					maxi = tmp;
					maxistr = tmpstring;
				}else if(tmp == maxi){
					if(tmpstring < maxistr){
						maxistr = tmpstring;
					}
				}else{
					//bugged here
				}
			}
			rotate();
		}
		for(int i=0;i<7;i++){
			cout << maxistr[i] << " ";
		}
		cout << maxistr[7] << endl;
	}
}