#include <iostream>
#include <cstdio>
#include <climits>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int a[] =   {4,1,4,1,2,1,2,1};
	int dic[] = {7,2,6,0,4,1,5,3};
	int b[8] = {};
	while(cin >> b[0]) {
		rep2(i,1,8) cin >> b[i];
		int cnt[8] = {};
		int min = INT_MAX;
		rep(i,8) {
			int ret = 0;
			rep(j,8) {
				if(a[(i+j)%8] < b[j]) ret += b[j] - a[(i+j)%8];
			}
			cnt[i] = ret;
			if(ret < min) min = ret;
		}
		int ans = -1;
		rep(i,8) {
			if(min == cnt[i]) {
				if(ans == -1) ans = i;
				else {
					if(dic[ans] > dic[i]) ans = i;
				}
			}
		}
		cout << a[ans];
		rep2(i,1,8) {
			cout << " " << a[(ans+i)%8];
		}
		cout << endl;
	}
	return 0;
}