#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
int p[3] = { 1,2,4 }; int x[8], y[8]; vector<pair<int, int>>vec;
int main() {
	while (cin >> x[0]) {
		for (int i = 1; i < 8; i++) { cin >> x[i]; }
		for (int i = 0; i < 6561; i++) {
			int sum = 0, sum2 = 0;
			for (int j = 0; j < 8; j++) { y[j] = (i / (int)pow(3, j)) % 3; }
			for (int j = 0; j < 8; j++) { if (p[y[j]] < x[i]) { sum += x[i] - p[y[j]]; } }
			for (int j = 0; j < 8; j++) { sum2 += p[y[j]] * (int)pow(10, 7 - j); }
			vec.push_back(make_pair(sum, sum2));
		}
		sort(vec.begin(), vec.end());
		for (int j = 0; j < 8; j++) { if (j) { cout << ' '; }cout << (vec[0].first / (int)pow(10, 7 - j)) % 10 << endl; }
	}
}