#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int mery[8] = { 4,1,4,1,2,1,2,1 };
void kaiten() {
	int a = mery[0];
	for (int b = 0; b < 7; b++)mery[b] = mery[b + 1];
	mery[7] = a;
}
int k() {
	int b = 0;
	for (int a : mery) {
		b = b * 10 + a;
	}
	return b;
}
signed main() {
	int a[8];
	while (cin >> a[0]) {
		for (int b = 1; b < 8; b++)cin >> a[b];
		int MIN = INT_MAX;
		int o = 0;
		for (int c = 0; c < 8; c++) {
			kaiten();
			int e = 0;
			for (int d = 0; d < 8; d++) {
				if (a[d] > mery[d])e += a[d] - mery[d];
			}
			if (e < MIN) {
				MIN = e;
				o = k();
			}
			if (e == MIN) {
				o = min(o, k());
			}
		}
		string p = to_string(o);
		for (int q = 0; q < 8; q++) {
			if (q)cout << " ";
			cout << p[q];
		}
		cout << endl;
	}
}