#include<cstdio>
using namespace std;
int main(void)
{
	int p[8],c[16]={4,1,4,1,2,1,2,1,4,1,4,1,2,1,2,1};
	int i,j,zyun[8]={1,6,2,8,4,7,3,5},sum,mn,mi;
	while(scanf("%d",&p[0])!=EOF)	{
		for(i=1;i<8;i++)	{
			scanf("%d",&p[i]);
		}
		mn=2000000000;
		for(i=0;i<8;i++)	{
			sum=0;
			for(j=0;j<8;j++)	{
				if(p[j]>c[i+j])	sum+=p[j]-c[i+j];
			}
//			printf("i=%d sum=%d\n",i,sum);
			if(mn>sum || (mn==sum && zyun[mi]<zyun[i]))	{
				mn=sum;	mi=i;
			}
		}
		printf("%d",c[mi]);
		for(i=1;i<8;i++)	{
			printf(" %d",c[mi+i]);
		}
		printf("\n");
	}
	return 0;
}
