#include <cstdio>
using namespace std;

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

int next(int i) {
	return i == 7 ? 0 : i + 1;
}

bool rec(int s, int i) {
	if (a[s] > a[i]) {
		return true;
	}
	else if (a[s] < a[i]) {
		return false;
	}
	else {
		return rec(s + 1, i + 1);
	}
}

int main(){
	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) {
		int l, c, min = 10000, s;
		for (int i = 0; i < 8; i++) {
			l = i;
			c = 0;
			for (int j = 0; j < 8; l = next(l), j++) {
				c += (a[l] - p[j] > 0 ? a[l] - p[j] : 0);
			}
			if (c < min) {
				min = c;
				s = i;
			}
			else if (c == min) {
				if (rec(s, i)) {
					s = i;
				}
			}
		}
		printf("%d", a[s]);
		for (int i = 1; i < 8; i++) {
			s = next(s);
			printf(" %d", a[s]);
		}
		printf("\n");
	}

	return 0;
}