#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll p[8];
ll table[8][8] = { { 1, 2, 1, 2, 1, 4, 1, 4 }, { 1, 2, 1, 4, 1, 4, 1, 2 },
{ 1, 4, 1, 2, 1, 2, 1, 4 }, { 1, 4, 1, 4, 1, 2, 1, 2 },
{ 2, 1, 2, 1, 4, 1, 4, 1, }, { 2, 1, 4, 1, 4, 1, 2, 1 },
{ 4, 1, 2, 1, 2, 1, 4, 1 }, { 4, 1, 4, 1, 2, 1, 2, 1 } };
ll ans[8];

int main(){
	while (cin>>p[0]){
		FOR(i, 1, 8)cin >> p[i];
		ll MIN= INF;
		REP(i,8){
			int n = 0;
			REP(j, 8){
				if (table[i][j] < p[j]){
					n += p[j] - table[i][j];
				}
			}
			if (n < MIN){
				REP(j, 8)ans[j] = table[i][j];
				MIN = n;
			}
		}
		REP(i, 8){
			if (i == 7)cout << ans[i] << endl;
			else cout << ans[i] << " ";
		}
	}
}