#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
int p[3] = { 1,2,4 }; int x[8], y[8]; int z[8] = { 2,0,2,0,1,0,1,0 };
int main() {
	while (cin >> x[0]) {
		int maxn = 100000000, maxid = 0;
		for (int i = 1; i < 8; i++) { cin >> x[i]; }
		for (int i = 0; i < 8; i++) {
			int sum = 0, sum2 = 0;
			for (int j = 0; j < 8; j++) { y[j] = z[(i + j) % 8]; }
			for (int j = 0; j < 8; j++) { if (p[y[j]] < x[j]) { sum += x[j] - p[y[j]]; } }
			for (int j = 0; j < 8; j++) { sum2 += p[y[j]] * (int)pow(10, 7 - j); }
			if (maxn > sum) { maxn = sum; maxid = sum2; }
			else if (maxn == sum && maxid > sum2) { maxid = sum2; }
		}
		for (int j = 0; j < 8; j++) { if (j) { cout << ' '; }cout << (maxid / (int)pow(10, 7 - j)) % 10; }cout << endl;
	}
	return 0;
}