#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
  int a[8];
  while((scanf("%d%d%d%d%d%d%d%d",
	       &a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7]))!=EOF){
    int b[8][8] = { {1,2,1,2,1,4,1,4},
		   {1,2,1,4,1,4,1,2},
		   {1,4,1,2,1,2,1,4},
		   {1,4,1,4,1,2,1,2},
		   {2,1,2,1,4,1,4,1},
		   {2,1,4,1,4,1,2,1},
		   {4,1,2,1,2,1,4,1},
		   {4,1,4,1,2,1,2,1}};
    int c[8];
    int i,j,d,m=0x1fffffff;
    for(i=0;i<8;i++){
      d=0;
      for(j=0;j<8;j++){
	d += (a[j]-b[i][j] < 0) ? 0 : a[j] - b[i][j];
      }
      if(m>d) {
	memcpy(c,b[i],sizeof(int)*8);
	m = d;
      }
    }
    for(i=0;i<8;i++){
      if(i==7) printf("%d\n",c[i]);
      else printf("%d ",c[i]);
    }
  }
  return 0;
}