#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>ps(8), cs{ 1,4,1,4,1,2,1,2 };
		for (int i = 0; i < 8; ++i) {
			if (!(cin >> ps[i])) {
				return 0;
			}
		}
		int ride_max = -1;
		vector<int>ans;
		for (int off = 0; off < 8; ++off) {
			rotate(cs.begin(), cs.begin() + off, cs.end());
			int canride = 0;
			for (int i = 0; i < 8; ++i) {
				canride += max(0, min(cs[i], ps[i]));
			}
			if (canride > ride_max) {

				ride_max = canride;
				ans = cs;
			}
			else if (canride == ride_max) {
				bool ok = false;
				for (int i = 0; i < 8; ++i) {
					if (ans[i] > cs[i]) {
						ok = true;
						break;
					}
					else if (ans[i] < cs[i]) {
						ok = false;
						break;
					}
					else {
						continue;
					}
				}
				if (ok) {
					ride_max = canride;
					ans = cs;
				}
			}
			rotate(cs.begin(), cs.begin() + 8 - off, cs.end());
		}
		for (int i = 0; i < 8; ++i) {
			cout << ans[i];
			if (i == 7)cout << endl;
			else cout << " ";
		}
	}

	return 0;
}