#include <cstdio>
#include <algorithm>
using namespace std;

const int r[] = {4, 1, 4, 1, 2, 1, 2, 1};

struct PA
{
	int s;
	int num;
	int V;
};

bool cmp(PA A, PA B)
{
	if (A.num == B.num){
		return (A.V < B.V);
	}
	return (A.num < B.num);
}

int main()
{
	int c[8];
	PA pa[8];
	
	while (1){
		memset(pa, 0, sizeof(pa));
		
		for (int i = 0; i < 8; i++){
			if (scanf("%d", &c[i]) == EOF) return 0;
			pa[i].s = i;
		}
		
		for (int i = 0; i < 8; i++){
			for (int j = 0; j < 8; j++){
				pa[i].V = pa[i].V * 10 + r[(i + j) % 8];
				
				if (r[(i + j) % 8] < c[j]){
					pa[i].num += c[j] - r[(i + j) % 8];
				}
			}
		}
/*		
		for (int i = 0; i < 8; i++){
			printf("%d %d\n", pa[i].V, pa[i].num);
		}
*/		
		sort(pa, pa + 8, cmp);
		
		bool f = false;
		for (int i = 0; i < 8; i++){
			if (f){
				printf(" ");
			}
			f = true;
			
			printf("%d", r[(pa[0].s + i) % 8]);
		}
		puts("");
	}
}