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

#define rep(i,a) for(int i = 0 ; i < a ; i ++)

int main(void){
	int mery[8]={4,1,4,1,2,1,2,1};
	int inp[8];
	while(cin>>inp[0]){
		int sum = 0 ; 
		for(int i = 1 ; i < 8 ; i ++){
			cin>>inp[i];
			sum += abs(mery[i] - inp[i]);
		}
		int min=sum;
//		cout<<sum;
		int minnum=0;
		for(int i = 1 ; i < 8 ; i ++){
			sum = 0 ;
			rep(j,8){
//				cout<<mery[i]<<"-"<<inp[j]<<endl;
				sum += abs(mery[(j+i)%7] - inp[j]);}
//			cout<<"sum"<<sum<<endl;
			if(min > sum){min = sum;minnum=i;} 
		}
		
		rep(i,7)cout<<mery[(minnum + i) % 8]<<" ";
		cout<<mery[(minnum + 7) % 7]<<endl;
	}
}