#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int c[8],n[8]={1,2,1,2,1,4,1,4},m,p,r[8]={1,5,2,6,4,8,3,7};

int main(){
	while(cin>>c[0]>>c[1]>>c[2]>>c[3]>>c[4]>>c[5]>>c[6]>>c[7]){
		int m=99999999;
		for(int i=0;i<8;i++){
			int sum=0;
			for(int j=0;j<8;j++)sum+=max(0,c[j]-n[(i+j)%8]);
			//cout<<sum<<" ";
			if(sum<m||sum==m&&r[i]<r[p]){m=sum;p=i;}
		}
		//cout<<"p"<<p<<" ";
		for(int i=0;i<8;i++){
			cout<<n[(i+p)%8];
			if(i<7)cout<<" ";
		}
		cout<<endl;
	}
}