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