#include <iostream>

using namespace std;

int pat[8][8] = {
	{4, 1, 4, 1, 2, 1, 2, 1},
	{1, 4, 1, 2, 1, 2, 1, 4},
	{4, 1, 2, 1, 2, 1, 4, 1},
	{1, 2, 1, 2, 1, 4, 1, 4},
	{2, 1, 2, 1, 4, 1, 4, 1},
	{1, 2, 1, 4, 1, 4, 1, 2},
	{2, 1, 4, 1, 4, 1, 2, 1},
	{1, 4, 1, 4, 1, 2, 1, 2},
};

const int inf = 99999;

int main()
{
	int c[8], s, t, u, v, a, b, d;
	
	while(cin >> c[0] >> c[1] >> c[2] >> c[3] >> c[4] >> c[5] >> c[6] >> c[7]){
		s = inf;
		t = 0;
		d = inf;
		for(int i = 0; i < 8; i++){
			u = 0;
			b = 0;
			for(int j = 0; j < 8; j++){
				a = v = c[j] - pat[i][j];
				if(v < 0){
					v = 0;
				}
				u += v;
				b += a;
			}
			if(s > u || (s == u && d > b)){
				s = u;
				t = i;
				d = b;
			}
		}
		
		cout << pat[t][0];
		for(int i = 1; i < 8; i++){
			cout << " " << pat[t][i];
		}
		cout << endl;
	}
	
	return 0;
}