#include<iostream>
#include<algorithm>
using namespace std;
const int l[16] = { 1,4,1,4,1,2,1,2,1,4,1,4,1,2,1,2 };
const int p[8] = { 1,3,7,5,0,2,6,4 };
int main() {
	int c[8];
	while (cin >> c[0]){
		for (int i = 1; i < 8; i++)cin >> c[i];
		int ans = 0, val = 114514;
		for (int i = 0; i < 8; i++){
			int q = p[i];
			int cnt = 0;
			for (int j = 0; j < 8; j++)
				cnt += max(0, c[j] - l[q + j]);
			if (val >= cnt) {
				val = cnt;
				ans = q;
			}
		}
		for (int i = 0; i < 8; i++){
			if (i)cout << ' ';
			cout << l[ans + i];
		}
		cout << endl;
	}
}