#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	array<int, 8>merry{ 4, 1, 4, 1, 2, 1, 2, 1 }, p;
	while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
		array<int, 8>c{ 1, 2, 1, 2, 1, 4, 1, 4 };
		int foo_min = INF;
		REP(i, 8) {
			int foo = 0; REP(j, 8)foo += max(0, p[j] - merry[(j + i) % 8]);
			if (foo_min > foo) {
				foo_min = foo;
				REP(j, 8) c[j] = merry[(j + i) % 8];
			} else if (foo_min == foo) {
				int a = 0, b = 0;
				for (int j = 0, k = 10000000; j < 8; ++j, k /= 10)a += c[j] * k;
				for (int j = 0, k = 10000000; j < 8; ++j, k /= 10)b += merry[(j + i) % 8] * k;
				if (a > b)REP(j, 8)c[j] = merry[(j + i) % 8];
			}
		}
		cout << c[0] << ' ' << c[1] << ' ' << c[2] << ' ' << c[3] << ' ' << c[4] << ' ' << c[5] << ' ' << c[6] << ' ' << c[7] << endl;
	}
}
