#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"


int main() {
	while (1) {

		vector<int>cs(8);
		vector<int>ps{ 4,1,4,1,2,1,2,1 };
		for (int i = 0; i < 8; ++i) {
			if (!(cin >> cs[i])) {
				return 0;
			}
		}
		int ans = 10000000;
		int aa = 0;
		vector<int>ansv(8);
		for (int off = 0; off < 8; ++off) {
			int nans = 0;
			vector<int>nansv;
			for (int k = 0; k < 8; ++k) {
				nans += max(0, cs[(k + off) % 8] - ps[k]);
				nansv.push_back(max(0, cs[(k + off) % 8]-ps[k]));
			}
			if (ans > nans) {
				ans = nans;
				ansv = nansv;
				aa = off;
			}
			else if (ans == nans) {
				bool ok = false;
				for (int i = 0; i < 8; ++i) {
					if (ansv[i] < nansv[i]) {
						ok = true;
						break;
					}
					else if (ansv[i]>nansv[i]) {
						ok = false;
						break;
					}
					else {

					}
				}
				if (ok) {
					ans = nans;
					ansv = nansv;
					aa = off;
				}
			}
		}
		for (int i = 0; i < 8; ++i) {
			cout << ps[(i+8-aa)%8];
			if (i == 7)cout << endl;
			else cout << " ";
		}
	}


	return 0;
}