#include <iostream>
#include <climits>
using namespace std;

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

void func(int *p, int k)
{
	for (int i = 0; i < 8; i++){
		p[i] = d[(i+k) % 8];
	}
	return;
}

int main(void)
{
	int p[8], res, t, td[8];
	long long m, tt;
	while (scanf("%d%d%d%d%d%d%d%d",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6],&p[7])!=EOF){
		res = INT_MAX;
		m = 59999 * 100000;
		for (int i = 0; i < 8; i++){
			func(td, i);
			t = tt = 0;
			for (int j = 0; j < 8; j++){
				t += max(p[j]-td[j],0);
				tt = tt * 10 + td[j];
			}
			if (t < res) {
				res = t;
				m = tt;
			}
			if(res == t && tt < m) {
				res = t;
				m = tt;
			}
		}
		for (int i = 0; i < 8; i++){
			p[7-i] = m % 10;
			m /= 10;
		}
		for (int i = 0; i < 8; i++){
			cout << p[i];
			if (i+1==8) puts("");
			else cout << " ";
		}
	}
	
	return 0;
}