#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); 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}};
	rep(i, 7) data.push_back(rotate(data[i]));
	sort(data.begin(), data.end());
	vector<int> b = vector<int>(8, 0);
	vector<int> s = vector<int>(8, 0);
	rep(i, 8) {
		scanf("%d",&b[i]);
	}
	int mn = INF;
	rep(i, data.size()) {
		int tmp = 0;
		rep(j, data[i].size()) {
			int d = b[j] - data[i][j];	
			if(d > 0) tmp += d;
		}
		s[i] = tmp;
		if(mn > tmp) mn = tmp;
	}
	rep(i, data.size()) {
		if(mn == s[i]) {
			rep(j, data[i].size() - 1) {
				printf("%d ", data[i][j]);
			}
			cout << data[i][data[i].size()-1] << endl;
			break;
		}
	}
	return 0;
}

/*
4 1 4 1 2 1 2 1 
 
 */