#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 8;

int checkV(int n, int h[N]){
    int ans = 0;
    for(int i = 1, cnt = 0; cnt < N; i *= 10, cnt++) ans += (h[(N - cnt - 1 + n) % N] * i);
    //debug
    //REP(i, N) cout <<h[(i + n) % N] <<" "; cout <<endl;
    //cout <<ans <<endl;
    return ans;
}

int main(){
    string inp;
    while(getline(cin, inp)){
        int h[N] = {4, 1, 4, 1, 2, 1, 2, 1};
        stringstream ss(inp);
        vector<int> c(N); REP(i, N) ss >>c[i];
        vector<int> ansv(N);

        int v = 1; REP(i, N) v += c[i];
        int ans = INF;
        REP(i, N){
            int sum = 0;
            REP(j, N) sum += max(0, c[j] - h[(i + j) % N]);
            if(sum < ans || (ans == sum && checkV(i, h) < v)){
                REP(k, N) ansv[k] = h[(k + i) % N];
                //debug
                //REP(k, N) cout <<ansv[k] <<" "; cout <<endl;
                v = checkV(i, h);
                ans = sum;
            }
        }
        cout <<ansv[0];
        FOR(i, 1, N) cout <<" " <<ansv[i];
        cout <<endl;
    }
    return 0;
}