#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int p[8];
	string str="1212141412121414";
	while(1){
		rep(i,0,8) cin>>p[i];
		if(cin.eof()) break;
		string tmp;
		int MIN=1e7;
		string ans;
		rep(i,0,8){
			tmp=str.substr(i,8);
			int dif=0;
			rep(j,0,8){
				if(p[j]>(int)(tmp[j]-'0')){
					dif+=p[j]-(int)(tmp[j]-'0');
				}
			}
			if(dif<MIN){
				MIN=dif;
				ans=tmp;
			}else if(dif==MIN){
				if(ans>tmp) ans=tmp;
			}
		}
		rep(i,0,8){
			if(i!=0) cout<<" ";
			cout<<ans[i];
		}
		cout<<endl;
	}
}