#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	char a[10][10] = {
		{"12121414"},
		{"12141412"},
		{"14121214"},
		{"14141212"},
		{"21214141"},
		{"21414121"},
		{"41212141"},
		{"41412121"}
	};
	int p[10] = {0};
	while(cin >> p[0]){
        for(int i = 1; i < 8; i++){
            scanf("%d",&p[i]);
        }
        int ret[10] = {0};
        int m = 1000000000;
        for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8; j++){
                if(p[j] > a[i][j]-'0')ret[i] += p[j] - (a[i][j]-'0');
            }
            m = min(m,ret[i]);
        }
        int ans = 0;
        for(int i = 0; i < 8; i++){
            if(ret[i] == m) ans = i;
        }
        end:;
        for(int i = 0; i < 8; i++){
            if(i != 0) printf(" %c",a[ans][i]);
            else printf("%c",a[ans][i]);
        }
        puts("");
	}
	return 0;
}