#include <iostream>
#include <algorithm>
using namespace std;

int cus(int p[], int c[], int j){
	int count = 0;
	for(int i = 0; i < 8; i++){
		count += min(p[i],c[(i+j)%8]);
	}
	return count;
}

void printc(int p[],int i){
	for(int j = 0; j < 8; j++){
		if(j != 0) cout << " ";
		cout << p[(i+j)%8];
	} 
	cout << endl;
}

int main(){
	int c[] = {
		1, 2, 1, 2, 
		1, 4, 1, 4
	};
	int p[8];
	while(cin >> p[0] >> p[1] >> p[2] >> p[3]
			>> p[4] >> p[5] >> p[6] >> p[7])
	{
		int count_max = 0;
		for(int i = 0; i < 8; i++){
			count_max = max(count_max, cus(p,c,i));
		}
		if(cus(p,c,0) == count_max){
			printc(c,0);
		}else if(cus(p,c,2) == count_max){
			printc(c,2);
		}else if(cus(p,c,6) == count_max){
			printc(c,6);
		}else if(cus(p,c,4) == count_max){
			printc(c,4);
		}else if(cus(p,c,1) == count_max){
			printc(c,1);
		}else if(cus(p,c,3) == count_max){
			printc(c,3);
		}else if(cus(p,c,7) == count_max){
			printc(c,7);
		}else{
			printc(c,5);
		}
	}
	return 0;
}