#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define fr first
#define sc second
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

void saiki(vector<int> v,vector<bool> u){
}

int main(){

    while(true){
	vector<int> p(8);
	vector<int> ans(8,4);
	vector<int> m;
	m.clear();
	REP(i,8){
	    cin >> p[i];
	    if(cin.eof()) break;
	}
	if(cin.eof()) break;
	m.PB(1);
	m.PB(2);
	m.PB(1);
	m.PB(2);
	m.PB(1);
	m.PB(4);
	m.PB(1);
	m.PB(4);
	int mini = 100000;
	int c = 0;
	REP(j,8){
	    c++;
	    int temp = 0;
	    REP(i,8){
		temp += max(p[i]-m[(i+j)%8],0);
	    }
	    if(mini >= temp){
		mini = temp;
		ll sum = 0;
		ll sum1 = 0;
		REP(k,8){
		    sum += pow(10,k-7) * (ll)m[(j+k)%8];
		    sum1 += pow(10,k-7) * (ll)ans[k];
		}

		if(sum < sum1){
		    REP(i,8){
			    ans[i] = m[(i+j)%8];
		    }
		}
	    }
	}
	cout << ans[0];
	REP(i,7){
	    cout << " " << ans[i+1];
	}
	cout << endl;
    }
    return 0;
}