#include <iostream>
#include <stdio.h>
using namespace std;

int f[8] = {4,1,4,1,2,1,2,1};
int n[8] = {41412121,14121214,41212141,12121414,21214141,12141412,21414121,14141212};
	
void output(int n){
	for(int i=0 ; i<8 ; i++){
		cout << f[(i+n)%8];
		(i==7)? cout << endl : cout << " "; 
	}
}

int main(){
	int p[8], c[8];
	int min1, min2, ans;

	while(cin>>p[0]>>p[1]>>p[2]>>p[3]>>p[4]>>p[5]>>p[6]>>p[7]){
		for(int i=0 ; i<8 ; i++) c[i]=0;
		min1 = 99999999;
		min2 = 99999999;
		
		for(int i=0 ; i<8 ; i++){
			for(int j=0 ; j<8 ; j++){
				int a = p[j] - f[(i+j)%8];
				if (a<0) a = 0;
				c[i] += a;
			}
		}
		for(int i=0 ; i<8 ; i++){
			if(min1>c[i]){
				ans = i;
				min1 = c[i];
				min2 = n[i];
			}else if(min1==c[i] && min2>n[i]){
				ans = i;
				min1 = c[i];
				min2 = n[i];
			}
		}
		output(ans);
	}

	return 0;
}