#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int pe[8]={0};
    int fj[] ={1,4,1,4,1,2,1,2,1,4,1,4,1,2,1,2};
    while(~scanf("%d",&pe[0])){
        reps(i,1,8)scanf("%d",&pe[i]);
        int comp = INF;
        int res[8]={0};
        rep(i,8){
            int x = 0;
            reps(j,i,i+8){
                x += (fj[j] >= pe[j-i]) ? 0 : pe[j-i] - fj[j];
            }
            if(comp == x){
                bool f = false;
                reps(j,i,i+8){
                    if(res[j-i] < fj[j])break;
                    else if(res[j-i] > fj[j]){
                        f = true;
                        break;
                    }
                }
                if(f){
                    reps(j,i,i+8)res[j-i] = fj[j];
                    comp = x;
                }
            }
            else if(comp > x){
                reps(j,i,i+8)res[j-i] = fj[j];
                comp = x;
            }
        }
        rep(i,7)printf("%d ",res[i]);
        printf("%d\n",res[7]);
    }
	return 0;
}