#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
	const int c[8][8] = {
		{1,2,1,2,1,4,1,4},
		{1,2,1,4,1,4,1,2},
		{1,4,1,2,1,2,1,4},
		{1,4,1,4,1,2,1,2},
		{2,1,2,1,4,1,4,1},
		{4,1,2,1,2,1,4,1},
		{4,1,4,1,2,1,2,1},
	};

	while(1) {
		int p[8];
		int min = -1;
		int k;

		for(int i = 0; i < 8; i++)
			cin >> p[i];
		
		if(cin.eof()) break;

		for(int i = 0; i < 8; i++) {
			int count = 0;

			for(int j = 0; j < 8; j++)
				count += ((p[j] - c[i][j] > 0) ? p[j] - c[i][j] : 0);
			
			if(min == -1 || count < min) {
				min = count;
				k = i;
			}
		}

		for(int j = 0; j < 7; j++)
			cout << c[k][j] << " ";
		cout << c[k][7] << endl;
	}
	return 0;
}