#include<iostream>
#include<climits>
using namespace std;

#define N 8

int main()
{
  int vehicle[N]={4,1,4,1,2,1,2,1},passenger[N];
  int i,j,wait,min,place;
  while(cin>>passenger[0]){
    for(i=1;i<N;i++)cin>>passenger[i];

    min=INT_MAX;place=0;
    for(i=0;i<N;i++){
      wait=0;
      for(j=0;j<N;j++){
	if(passenger[j]-vehicle[(j+i)%N]>0)wait+=passenger[j]-vehicle[(j+i)%N];
      }
      if(min>wait){min=wait;place=i;}
      else if(min==wait){
	int t=0,d=1;
	for(j=N-1;j>=0;j--){
	  t+=vehicle[(j+i)%N]*d-vehicle[(j+place)%N]*d;
	  d*=10;
	}
	if(t<0)place=i;
      }
    }

    for(i=0;i<N;i++){
      if(i!=0)cout<<' ';
      cout<<vehicle[(i+place)%N];
    }
    cout<<endl;
  }
}