//48
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(){
  for(;;){
    int a[8];
    for(int i=0;i<8;i++){
      cin>>a[i];
      if(!cin)return 0;
    }
    int g=1<<30;
    int v[]={1,4,1,4,1,2,1,2};
    int b[8];
    for(int i=0;i<8;i++){
      rotate(v,v+1,v+8);
      int r=0;
      for(int j=0;j<8;j++){
	r+=max(0,a[j]-v[j]);
      }
      if(r<g||(r==g&&lexicographical_compare(v,v+8,b,b+8))){
	memcpy(b,v,sizeof(b));
	g=r;
      }
    }
    for(int i=0;i<8;i++){
      cout<<b[i]<<((i==7)?'\n':' ');
    }
  }
  return 0;
}