#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    int p[8],c[8][8]={{1,2,1,2,1,4,1,4},
                        {1,2,1,4,1,4,1,2},
                        {1,4,1,2,1,2,1,4},
                        {1,4,1,4,1,2,1,2},
                        {2,1,2,1,4,1,4,1},
                        {2,1,4,1,4,1,2,1},
                        {4,1,2,1,2,1,4,1},
                        {4,1,4,1,2,1,2,1}};
    while(cin>>p[0]){
        for(int i=1;i<8;i++){
            cin>>p[i];
        }
        int q=0,ans=1000000,over=0;
        for(int i=0;i<8;i++){
            over=0;
            for(int j=0;j<8;j++){
                int o=0;
                if(p[j]-c[i][j]<0)o=0;
                else o=p[j]-c[i][j];
                over+=o;
            }
            if(over<ans){
                ans=over;
                q=i;
            }
        }
        for(int i=0;i<7;i++){
            cout<<c[q][i]<<" ";
        }
        cout<<c[q][7]<<endl;
    }
    return 0;
}