#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define INF (~(1 << 31))
using namespace std;

int f(vector< int > &v){
	int res = 0;
	
	for(vector< int >::iterator it = v.begin(); it != v.end(); ++it){
		res = res * 10 + (*it);
	}
	
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int p[8];
	int m[8] = {4, 1, 4, 1, 2, 1, 2, 1};
	vector< int > c(m, m + 8);
	
	while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
		
		int min = INF;
		int res = INF;
		stringstream ss;
		string str;
		
		REP(i, 8){
			int r = 0;
			rotate(c.begin(), c.begin() + 1, c.end());
			
			REP(j, 8){
				r += (p[j] - c[j] < 0 ? 0 : p[j] - c[j]);
			}
			
			if(r < min){
				min = r;
				res = f(c);
			}else if(r == min){
				if(f(c) < res){
					res = f(c);
				}
			}
		}
		
		REP(i, 8){
			ss << (i ? " " : "") << (res % 10);
			res /= 10;
		}
		
		str = ss.str();
		reverse(ALL(str));
		
		cout << str << endl;
	}
	
	return 0;
}