#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;


int main(){

	int p[8],min,min_pattern,tmp,pattern[8],tmp_sum,S;
	pattern[0] = 12121414,
	pattern[1] = 12141412,
	pattern[2] = 14121214,
	pattern[3] = 14141212,
	pattern[4] = 21214141,
	pattern[5] = 21414121,
	pattern[6] = 41212141,
	pattern[7] = 41412121;

	while(scanf("%d %d %d %d %d %d %d %d ",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6],&p[7]) != EOF){
		min = 2147483647;

		for(int i=0; i <= 7; i++){
			tmp = pattern[i];
			tmp_sum = 0;
			S = 10000000;
			for(int k=0; k <= 7; k++){
				if(p[k] < (tmp/S))tmp_sum += 0;
				else{
					tmp_sum += p[k] - (tmp/S);
				}
				tmp %= S;
				S /= 10;
			}
			if(min > tmp_sum){
				min = tmp_sum;
				min_pattern = i;
			}
		}

		S = 10000000;
		tmp = pattern[min_pattern];
		printf("%d",tmp/S);
		tmp %= S;
		S /= 10;
		for(int i=1; i<=7; i++){
			printf(" %d",tmp/S);
			tmp %= S;
			S /= 10;
		}
		printf("\n");
	}
    return 0;
}