#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int p[8];
	while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
		int jn[8][8] = { {1,2,1,2,1,4,1,4},{1,2,1,4,1,4,1,2} ,{1,4,1,2,1,2,1,4},{1,4,1,4,1,2,1,2},
		{2,1,2,1,4,1,4,1},{2,1,4,1,4,1,2,1},{4,1,2,1,2,1,4,1},{4,1,4,1,2,1,2,1} };

		int n = 5000000;
		int ans;

		for (int i = 0;i < 8;i++) {
			int a = 0;
			for (int j = 0;j < 8;j++) {
				a +=max(0,p[j]-jn[i][j]);//norenai
			}
			if (n > a) {
				ans = i;
				n = a;
			}
		}
		for (int i = 0;i < 8;i++) {
			cout << jn[ans][i];
			if (i != 7)cout << ' ';
		}
		cout << endl;
	}
	return 0;
}