#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int p[8];
	int mx;
	while(cin>>p[0]>>p[1]>>p[2]>>p[3]>>p[4]>>p[5]>>p[6]>>p[7]){
		mx=0;
		int buf,res=0;
		buf=min(p[0],1)+min(p[1],2)+min(p[2],1)+min(p[3],2)+min(p[4],1)+min(p[5],4)+min(p[6],1)+min(p[7],4);
		if(buf>mx){mx=buf;res=0;}
		buf=min(p[0],1)+min(p[1],2)+min(p[2],1)+min(p[3],4)+min(p[4],1)+min(p[5],4)+min(p[6],1)+min(p[7],2);
		if(buf>mx){mx=buf;res=2;}
		buf=min(p[0],1)+min(p[1],4)+min(p[2],1)+min(p[3],2)+min(p[4],1)+min(p[5],2)+min(p[6],1)+min(p[7],4);
		if(buf>mx){mx=buf;res=6;}
		buf=min(p[0],1)+min(p[1],4)+min(p[2],1)+min(p[3],4)+min(p[4],1)+min(p[5],2)+min(p[6],1)+min(p[7],2);
		if(buf>mx){mx=buf;res=4;}
		buf=min(p[0],2)+min(p[1],1)+min(p[2],2)+min(p[3],1)+min(p[4],4)+min(p[5],1)+min(p[6],4)+min(p[7],1);
		if(buf>mx){mx=buf;res=1;}
		buf=min(p[0],2)+min(p[1],1)+min(p[2],4)+min(p[3],1)+min(p[4],4)+min(p[5],1)+min(p[6],2)+min(p[7],1);
		if(buf>mx){mx=buf;res=3;}
		buf=min(p[0],4)+min(p[1],1)+min(p[2],2)+min(p[3],1)+min(p[4],2)+min(p[5],1)+min(p[6],4)+min(p[7],1);
		if(buf>mx){mx=buf;res=7;}
		buf=min(p[0],4)+min(p[1],1)+min(p[2],4)+min(p[3],1)+min(p[4],2)+min(p[5],1)+min(p[6],2)+min(p[7],1);
		if(buf>mx){mx=buf;res=5;}
		int i;
		int seat[]={1,2,1,2,1,4,1,4};
		for(i=0;i<7;i++){
			cout<<seat[(res+i)%8]<<" ";
		}
		cout<<seat[(res+7)%8]<<endl;
	}
	return 0;
}