#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }


string solve(const vci& p) {
	string cperm = "14141212";
	string mperm = "44444444";
	int mcust = iINF;
	
	for_(i, 0, 8) {
		int cust = 0;
		
		for_(j, 0, 8) {
			int sub = p[j] - (cperm[j]-'0');
			if (sub>0) cust += sub;
		}
		
		if (cust < mcust) {
			mcust = cust;
			mperm = cperm;
		} else if (cust==mcust) {
			if (cperm < mperm) mperm = cperm;
		}
		
		cperm = cperm.substr(1, 7) + cperm[0];
	}
	
	return mperm;
}

int main() {
	vci p(8);
	
	while (cin>>p[0]) {
		for_(i, 1, 8) cin>>p[i];
		
		string ans = solve(p);
		for_(i, 0, 7) cout << ans[i] << " ";
		cout << ans[7] << endl;
	}
	
	return 0;
}