#include<iostream>
#include<algorithm>
#include<cmath>

#define MAX 8

using namespace std;

int main(void){
	while( true ){
		int ppl[MAX];
		int gondra[MAX] = {4,1,4,1,2,1,2,1};
		int ans[MAX];
		unsigned int leftPpl = 1 << 22;
		unsigned int Vmin = 1 << 22;

		for(int i = 0; i < MAX; i++) cin >>ppl[i];
		if( cin.eof() ) break;

		for(int i = 0; i < MAX; i++){
			unsigned int V = 0;
			unsigned int P = 0;
			for(int j = 0; j < MAX; j++){
				V += (unsigned int)pow(10.0, MAX - j - 1) * gondra[j];
				P += max(0, ppl[j] - gondra[j]);
			}
			if( P < leftPpl ){
				leftPpl = P;
				Vmin = V;
				copy(gondra,gondra+sizeof(gondra)/sizeof(*gondra),ans);
			}else if( P == leftPpl && V < Vmin ){
				Vmin = V;
				copy(gondra,gondra+sizeof(gondra)/sizeof(*gondra),ans);
			}
			rotate(gondra, gondra+1, gondra+sizeof(gondra)/sizeof(*gondra));
		}

		cout << ans[0]; 
		for(int i = 1; i < MAX; i++){
			cout << " " << ans[i];
		}
		cout << '\n';
	}
	return 0;
}