#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int capa[8] = {4, 1, 4, 1, 2, 1, 2, 1};
int p[8];


int calcRest(void)
{
	int rest = 0;
	
	for (int i=0; i<8; i++)
	{
		if (p[i] > capa[i])
		{
			rest += p[i] - capa[i];
		}
	}
	
	return rest;
}


void rotateCapa(void)
{
	int temp = capa[0];
	for (int i=0; i<7; i++)
	{
		capa[i] = capa[i+1];
	}
	capa[7] = temp;
}


int main()
{
	int rest, minRest = 100000;
	string minRestStr, restStr;
	stringstream ss;
	
	while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7])
	{
		minRest = 10000000;
		for (int i=0; i<8; i++)
		{
			rotateCapa();
			rest = calcRest();
			ss.str("");
			if (rest == minRest)
			{
				ss << capa[0] << " " << capa[1] << " " << capa[2] << " " << capa[3] << " " << capa[4] << " " << capa[5] << " " << capa[6] << " " << capa[7];
				restStr = ss.str();
				if (restStr < minRestStr)
				{
					minRestStr = restStr;
				}
			}
			if (rest < minRest)
			{
				minRest = rest;
				ss << capa[0] << " " << capa[1] << " " << capa[2] << " " << capa[3] << " " << capa[4] << " " << capa[5] << " " << capa[6] << " " << capa[7];
				minRestStr = ss.str();
			}
		}
		cout << minRestStr << endl;
	}
	
	return 0;
}