#include<iostream>
#include<algorithm>
using namespace std;
#define N 8

int q[N];

void compute(){
    int T[8] = {4, 1, 4, 1, 2, 1, 2, 1};
    int A[8];

    int maxv = 0;
    int maxs = 0;
    for ( int i = 0; i < N; i++ ){
	int sum = 0;
	int s = 0, p = 10000000;
	for ( int j = 0; j < N; j++ ){
	    sum +=  min(T[j], q[j]);
	    s += T[j]*p;
	    p /= 10;
	}
	if ( sum > maxv ){
	    maxs = s;
	    maxv = sum;
	    for ( int k = 0; k < N; k++ ) A[k] = T[k];
	} else if ( sum == maxv && maxs > s){
	    for ( int k = 0; k < N; k++ ) A[k] = T[k];
	}
	
	int tmp = T[0];
	for ( int i = 0; i < N-1; i++ ){
	    T[i] = T[i+1];
	}
	T[N-1] = tmp;
	// rotate;
    }

    for ( int i = 0; i < N; i++ ){
	cout << A[i] << " ";
    }
    cout << endl;
}

main(){
    while( cin >> q[0] ){
	for ( int i = 1; i < N; i++ ) cin >> q[i];
	compute();
    }
}