#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
vector<int> rotate(vector<int> v) {
	vector<int> ret;
	for(int i = 1; i < v.size(); i++) {
		ret.push_back(v[i]);
	}
	ret.push_back(v[0]);
	return ret;
}
int main() {
	vector<vector<int>> data = {{4,1,4,1,2,1,2,1}};
	vector<int> b = vector<int>(8, 0);

	rep(i, 7) data.push_back(rotate(data[i]));
	sort(data.begin(), data.end());
	while(cin >> b[0] >> b[1] >> b[2] >> b[3] >> b[4] >> b[5] >> b[6] >> b[7]) {
		vector<int> s = vector<int>(8, 0);
		int mn = INF;
		rep(i, data.size()) {
			rep(j, data[i].size()) {
				s[i] += max(0, b[j] - data[i][j]);
			}
			if(mn > s[i]) mn = s[i];
		}
		rep(i, data.size()) {
			if(mn == s[i]) {
				printf("%d", data[i][0]);
				reps(j, 1, data[i].size()) printf(" %d", data[i][j]);
				puts("");
				break;
			}
		}
	}
	return 0;
}