#include <iostream>
using namespace std;
const int dorder[8][8] = {
	{1, 2, 1, 2, 1, 4, 1, 4},
	{1, 2, 1, 4, 1, 4, 1, 2},
	{1, 4, 1, 2, 1, 2, 1, 4},
	{1, 4, 1, 4, 1, 2, 1, 2},
	{2, 1, 2, 1, 4, 1, 4, 1},
	{2, 1, 4, 1, 4, 1, 2, 1},
	{4, 1, 2, 1, 2, 1, 4, 1},
	{4, 1, 4, 1, 2, 1, 2, 1},
};

int main () {
	while (true) {
		int minremain = 0;
		int minidx = -1;
		int p[8];
		for (int i = 0; i < 8; i++) {
			cin >> p[i];
			minremain += p[i];
		}
		if (!cin.good()) break;
		
		for (int i = 0; i < 8; i++) {
			int rem = 0;
			for (int j = 0; j < 8; j++) {
				rem += max(0, p[j] - dorder[i][j]);
			}
			if (rem < minremain) {
				minremain = rem;
				minidx = i;
			}
		}
		cout << dorder[minidx][0];
		for (int i = 1; i < 8; i++) {
			cout << ' ' << dorder[minidx][i];
		}
		cout << endl;
	}
	return 0;
}