#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
using namespace std;

const int latte[8]={4,1,4,1,2,1,2,1},pri[8]={0,5,1,7,3,6,2,4};

int main(){
	int human[8];
	while(cin>>human[0]){
		int ansv=1000000000,anspri=10,ans;
		for(int i=1;i<8;i++){
			cin>>human[i];
		}
		for(int i=0;i<8;i++){
			int v=0;
			for(int j=0;j<8;j++){
				v += max(0,human[j]-latte[(i+j)%8]);
			}
			if(ansv>v || (ansv==v && anspri<pri[i])){
				ansv = v; anspri = pri[i]; ans = i;
			}
		}
		printf("%d",latte[ans]);
		for(int i=1;i<8;i++){
			printf(" %d",latte[(ans+i)%8]);
		}puts("");
	}
	return 0;
}