#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	vector<int> p(8);
	while(cin >> p[0])
	{
		for(int i = 1; i < 8; ++i)
		{
			cin >> p[i];
		}
		int c[8] = {4, 1, 4, 1, 2, 1, 2, 1};
		int max_people = 0;
		int pos = 0;
		for(int i = 0; i < 8; ++i)
		{
			int people = 0;
			for(int j = 0; j < 8; ++j)
			{
				if(p[j] >= c[(i + j) % 8])
				{
					people += c[(i + j) % 8];
				}
				else
				{
					people += p[j];
				}
			}
			if(max_people < people)
			{
				max_people = people;
				pos = i;
			}
		}
		for(int i = 0; i < 7; ++i)
		{
			cout << c[(pos + i) % 8] << " ";
		}
		cout << c[(pos + 7) % 8] << endl;
	}
}

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