#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){

	int p[8], n[8], least, cnt;
	const int a[8] = {4,1,4,1,2,1,2,1};
	vector<int> vc;
	string str[8];

	while(cin >> p[0]){
		for(int i=1; i<8; i++){
			cin >> p[i];
		}
		
		cnt = 0;
		fill(n, n+8, 0);
		for(int i=0; i<8; i++){
			for(int j=0; j<8; j++){
				if(a[(i+j)%8] < p[j]){
					n[i] += p[j] - a[(i+j)%8];
				}
			}

			if(i == 0 || n[i] < n[least]){
				least = i;
				cnt = 1;
				vc.clear();
				vc.push_back(i);
			}
			else if(n[i] == n[least]){
				cnt++;
				vc.push_back(i);
			}
		}
		
		if(cnt == 1){
			for(int i=0; i<8; i++){
				cout << a[(vc[0] + i) % 8];
				if(i == 7) cout << endl;
				else cout << " ";
			}
		}
		else {
			for(int i=0; i<cnt; i++){
				for(int j=0; j<8; j++){
					str[i] += a[(vc[i] + j) % 8] + '0';
				}
			}
			sort(str, str+cnt);
			for(int i=0; i<8; i++){
				cout << str[0][i];
				if(i == 7) cout << endl;
				else cout << " ";
			}
		}
	}

	return 0;

}