#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a[8];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7])
	{
		string merry="41412121";
		string ans;
		int cans=10000000;
		for(int i = 0; i < 8; ++i)
		{
			int cnt=0;
			for(int j = 0; j < 8; ++j)
			{
				int num=merry[j]-'0';
				cnt+=a[j]-num<0?0:a[j]-num;
			}
			if(cnt<cans)
			{
				cans=cnt;
				ans=merry;
			}
			else if(cnt==cans&&merry<ans)
			{
				ans=merry;
			}
			char tmp=merry[0];
			for(int j = 1; j < 8; ++j)
			{
				merry[j-1]=merry[j];
			}
			merry[7]=tmp;
		}
		for(int i = 0; i < 8; ++i)
		{
			if(i==0) cout<<ans[0];
			else cout<<" "<<ans[i];
		}
		cout<<endl;
	}
  return 0;
}