#include <bits/stdc++.h>
using namespace std;

int main()
{
	vector<int> ff = {4, 1, 4, 1, 2, 1, 2, 1};
	vector<int> v(8);
	while (true){
		for (int i = 0; i < 8; i++){
			if (scanf("%d", &v[i]) == EOF) return 0;
		}
		pair<int, vector<int>> mini;
		mini.first = 114514;
		for (int i = 0; i < 8; i++){
			int cnt = 0;
			vector<int> f;
			for (int j = 0; j < 8; j++){
				int x = (i + j) % 8;
				f.push_back(ff[x]);
				cnt += max(v[j] - ff[x], 0);
			}
			mini = min(mini, make_pair(cnt, f));
		}
		for (int i = 0; i < 8; i++){
			if (i) printf(" ");
			printf("%d", mini.second[i]);
		}
		puts("");
	}
	return 0;
}