#include<bits/stdc++.h>
using namespace std;
int main()
{
    int fly[]={4,1,4,1,2,1,2,1},peo[8],big=0,num=0,point=0;
    while(cin>>peo[0]){
        for(int i=1;i<8;i++)cin>>peo[i];
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(i+j>7){
                    if(fly[i+j-8]<peo[j])num+=fly[i+j-8];
                    else num+=peo[j];
                }
                else{
                    if(fly[i+j]<peo[j])num+=fly[i+j];
                    else num+=peo[j];
                }
            }
            if(big<num){
                big=num;
                point=i;
            }
            else if(big==num){
                for(int j=0;j<8;j++){
                    if(i+j>7){
                        if(point+j>7){
                            if(fly[i+j-8]>fly[point+j-8])break;
                            else if(fly[i+j-8]<fly[point+j-8]){
                                point=i;
                                break;
                            }
                        }
                        else{
                            if(fly[i+j-8]>fly[point+j])break;
                            else if(fly[i+j-8]<fly[point+j-8]){
                                point=i;
                                break;
                            }
                        }
                    }
                else{
                    if(fly[i+j]>fly[point+j])break;
                    else if(fly[i+j]<fly[point+j]){
                            point=i;
                            break;
                        }
                    }
                }
            }
            num=0;
        }
        for(int i=0;i<8;i++){
                if(i==0)cout<<fly[i+point];
                else if(point+i>7)cout<<" "<<fly[point+i-8];
                else cout<<" "<<fly[point+i];
            }
            cout<<endl;
            point=0;big=0;
    }
}