#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

int r[] = {1,4,1,4,1,2,1,2,1,4,1,4,1,2,1,2};

int main(){
	int p[8];
	while(1){
		for(int i = 0;i < 8;i++){
			if(!(cin >> p[i])) return 0;
		}
		int mi = 1e+9,m;
		for(int i = 0;i < 8;i++){
			int cnt = 0;
			for(int j = 0;j < 8;j++){
				cnt += max(0,p[j] - r[i + j]);
			}
			if(mi > cnt){
				int tmp = 0;
				for(int k = 0;k < 8;k++) tmp = tmp * 10 + r[i + k];
				m = tmp;
				mi = cnt;
			}else if(mi == cnt){
				int tmp = 0;
				for(int k = 0;k < 8;k++) tmp = tmp * 10 + r[i + k];
				m = min(tmp,m);
			}
		}
		vector<int> v;
		for(int i = 0;i < 8;i++) v.push_back((m / (int)pow(10.0,i)) % 10);
		for(int i = 7;i >= 1;i--) cout << v[i] << " ";
		cout << v[0] << endl;
	}
	return 0;
}