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