#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

vector<int> merry = {1,2,1,2,1,4,1,4};

int cannotGetIn(vector<int> c, int n) {
    vector<int> merry2;
    FOR(i,n,8) {
        merry2.push_back(merry[i]);
    }
    REP(i,n) {
        merry2.push_back(merry[i]);
    }
    int cnt = 0;
    REP(i,8) {
        cnt += max(0,c[i]-merry2[i]);
    }
    return cnt;
}

void printMerry(int n) {
    vector<int> merry2;
    FOR(i,n,8) {
        merry2.push_back(merry[i]);
    }
    REP(i,n) {
        merry2.push_back(merry[i]);
    }
    REP(i,7) {
        cout << merry2[i] << " ";
    }
    cout << merry2.back() << endl;
}

int main() {
    vector<int> c(8);
    while(cin>>c[0]>>c[1]>>c[2]>>c[3]>>c[4]>>c[5]>>c[6]>>c[7]) {
        int over = 100;
        int ind = 0;
        REP(i,8) {
            int l = cannotGetIn(c, i);
            if (l < over) {
                over = l;
                ind = i;
            }
        }
        printMerry(ind);
    }
    return 0;
}