#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int c[8] = { 1 ,4 ,1, 4, 1, 2, 1, 2 };
	int p[8];
	for (; cin >> p[0];) {
		string ans = "";
		rep(i, 1, 8)cin >> p[i];
		int M = -INF;
		rep(i, 0, 8) {//?????¢
			int temp = 0;
			string temps = "";
			rep(j, 0, 8) {
				int add = p[j];
				if (p[j] > c[(j + i) % 8])add = c[(j + i) % 8];
				temp += add;
				temps += char(c[(j + i) % 8] + '0');
			}
			if (temp == M) {
				ans = min(ans, temps);
			}
			else if (temp > M) {
				ans = temps;
				M = temp;
			}
		}
		cout << ans[0];
		rep(i, 1, 8)cout << " " << ans[i];
		cout << endl;
	}
	return 0;
}