#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int c[] = {4, 1, 4, 1, 2, 1, 2, 1, 4, 1, 4, 1, 2, 1, 2, 1};
int s[] = {41412121,
		   14121214,
		   41212141,
		   12121414,
		   21214141,
		   12141412,
		   21414121,
		   14141212 };

void printv(int v[], int len) {
	for (int i = 0; i < len; i++)
		cout << v[i] << " ";
	cout << endl;
}

void solve(int p[8]) {
	int ans = 0;
	int minl = 50000000;
	for (int i = 0; i < 8; i++) {
		int l = 0;
		for (int j = 0; j < 8; j++) {
			l += ((p[j] - c[i + j]) > 0 ? p[j] - c[i + j] : 0);
		}
		if (minl > l) {
			ans = i;
			minl = l;
		}
		else if (minl == l) {
			if (s[ans] > s[i]) {
				ans = i;
				minl = l;
			}
		}
	}
	printv(&c[ans], 8);
}

int main() {
	int p[8];
	while (cin >> p[0]) {
		for (int i = 1; i < 8; i++)
			cin >> p[i];
		solve(p);
	}
	return 0;
}