#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<int,int> P;
typedef complex<double> CP;
typedef long long ll;

int mer[10];
string s="14141212";
int tmp[10];
int peo[10];
vector< P > res;

int main(){
	rep(i,8){
		mer[i]=s[i]-'0';
	}
	while(cin>>tmp[0]){
		res.clear();
		rep(i,7){
			cin>>tmp[i+1];
		}
		rep(i,8){
			/*
			rep(j,8) cout<<tmp[j]<<" ";
			cout<<endl;
			*/
			int sum=0;
			rep(j,8){
				int t=i+j;
				t%=8;
				//peo[j]=tmp[t];
				if(tmp[j]-mer[t]<0){
				}
				else sum+=tmp[j]-mer[t];
				
				
				//cout<<mer[t]<<" ";
			}
			//cout<<endl;
			P t;
			t.F=sum; t.S=i;
			res.PB(t);
			//cout<<"sum= "<<sum<<endl<<endl;
		}
		sort(ALL(res));
		
		rep(i,8){
			int t=i+res[0].S;
			t%=8;
			if(i!=0) cout<<" ";
			cout<<mer[t];
		}
		
		cout<<endl;
		
	}
			
			
			
	return 0;
}