#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int a[8];
int main() {
	while (1) {
		string m = "41412121";
		rep(i, 8) {
			if (!(cin >> a[i]))return 0;
		}
		string k;
		int M = INT_MAX;
		rep(i, 8) {
			rotate(m.begin(), m.begin() + 1, m.end());
			int s = 0;
			rep(j, 8)s += max(0, a[j] + '0' - m[j]);
			if (s < M) { M = s; k = m; }
			if (s == M&&m < k)k = m;
		}
		rep(i, 8)cout << k[i] << (i == 7 ? "\n" : " ");
	}
}