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

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