#include <iostream>

using namespace std;
int d[8] = {1, 2, 1, 2, 1, 4, 1, 4};

void solve()
{
	int c[16];
	while(cin >> c[0] >> c[1] >> c[2] >> c[3] >> c[4] >> c[5] >> c[6] >> c[7])
	{
		for(int i = 0; i < 8; ++i)
		{
			c[i + 8] = c[i];
		}
		int MinRest = 999999999;
		int MinNumber = 999999999;
		int index = 0;
		for(int a = 0; a < 8; ++a)
		{
			int Rest = 0;
			for(int i = 0; i < 8; ++i)
			{
				if(c[i + a] >= d[i])
				{
					Rest += c[i + a] - d[i];
				}
			}
			if(MinRest > Rest)
			{
				MinRest = Rest;
				int temp = 1;
				MinNumber = 0;
				for(int i = a + 7; i >= a; --i)
				{
					MinNumber += c[i] * temp;
					temp *= 10;
				}
				index = a;
			}
			else if(MinRest == Rest)
			{
				int Number = 0;
				int temp = 1;
				for(int i = a + 7; i >= a; --i)
				{
					Number += c[i] * temp;
					temp *= 10;
				}
				if(MinNumber > Number)
				{
					MinNumber = Number;
					index = a;
				}
			}
		}
		for(int i = 8 - index; i < 8; ++i)
		{
			cout << d[i] << " ";
		}
		for(int i = 0; i < 8 - index - 1; ++i)
		{
			cout << d[i] << " ";
		}
		cout << d[7 - index] << endl;
	}
}

int main()
{
	solve();
	return(0);
}