#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int hyou[8] = {1, 2, 1, 2, 1, 4, 1, 4};
	int a[8];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7]) {
		int kari;
		int sum = 0;
		for (int i = 0; i < 8; i++) {
			sum += a[i];
		}
		int MIN = sum;
		long long int p;
		for (int i = 0; i < 8; i++) {
			int k = sum;
			for (int j = 0; j < 8; j++) {
				if (hyou[j] >= a[j]) {
					k -= a[j];
				} else {
					k -= hyou[j];
				}
			}
			if (MIN > k){
				MIN = k;
				p = 0;
				for (int j = 0; j < 8; j++) {
					p *= 10;
					p += hyou[j];
				}
			} else if (MIN == k) {
				long long int karikari = 0;
				for (int j = 0; j < 8; j++) {
					karikari *= 10;
					karikari += hyou[j];
				}
				p = min(karikari, p);
			}
			kari = hyou[0];
			for (int j = 0; j < 7; j++) {
				hyou[j] = hyou[j+1];
			}
			hyou[7] = kari;
		}
		for (int i = 7; i >= 0; i--) {
			a[i] = p % 10;
			p /= 10;
		}
		cout << a[0];
		for (int i = 1; i < 8; i++) {
			cout << ' ' << a[i];
		}
		cout << endl;
	}
	return 0;
}