#include <iostream>
#include <iomanip>
#include <limits.h>

using namespace std;

int max(int x, int y)
{
	return x>y ? x : y;
}

int main()
{
	int capacity[8] = {4, 1, 4, 1, 2, 1, 2, 1};
	int index[8] = {3, 5, 1, 7, 4, 6, 2, 0};
	
	int p[8];
	while ( cin >> p[0] ) {
		for (int i=1; i<8; i++) cin >> p[i];
		
		int minWaiting = INT_MAX;
		int minWaitingIndex = 0;
		
		for (int j=0; j<8; j++) {
			int headIndex = index[j];
			int numOfWaiting = 0;
			for (int i=0; i<8; i++) {
				numOfWaiting += max(p[i] - capacity[(headIndex+i)%8], 0);
			}
			if (minWaiting > numOfWaiting) {
				minWaiting = numOfWaiting;
				minWaitingIndex = headIndex;
			}
		}
		
		for (int i=0; i<7; i++) {
			cout << capacity[(minWaitingIndex+i)%8] << " ";
		}
		cout << capacity[(minWaitingIndex+7)%8] << endl;
	}
	
	return 0;
}