#include<stdio.h>
#include<algorithm>
#include<map>
#include<string>
#include<sstream>
#include<limits.h>
using namespace std;
int main(void)
{
	const int N = 8;
	int c[N] = {1,2,1,2,1,4,1,4,};
	int p[N];
	int i,j,a,V;
	map<int,int> m;
	for(;;)
	{
		for(i = 0; i < N; ++i)
		{
			if(scanf("%d", &p[i]) != 1)
				return 0;
		}
		for(i = 0; i < N; i++)
		{
			V = a = 0;
			for(j = 0; j < N; j++)
			{
				V = V*10+c[(i+j)%N];
				a += max(0, p[j]-c[(i+j)%N]);
			}
			m[V] = a;
		}
		int least = INT_MAX, index;

		for(map<int,int>::iterator ite = m.begin();
			ite != m.end();
			++ite)
		{
			if(least > ite->second)
			{
				least = ite->second;
				index = ite->first;
			}
		}
		stringstream ss;
		ss << index;
		string str = ss.str();
		for(i = 0; i < str.size(); i++)
		{
			printf("%s%d", (i?" ":""), str[i]-'0');
		}
		putchar('\n');
	}
	return 1;
}