#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;
}

vector<int> getMerry(int n) {
    vector<int> merry2;
    FOR(i,n,8) {
        merry2.push_back(merry[i]);
    }
    REP(i,n) {
        merry2.push_back(merry[i]);
    }
    return merry2;
}

int getNum(vector<int> v) {
    int ans = 0;
    int ord = 10000000;
    REP(i,8) {
        ans += v[i]*ord;
        ord /= 10;
    }
    return ans;
}

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 ans = 1e9;
        REP(i,8) {
            int l = cannotGetIn(c, i);
            if (l == over) {
                ans = min(ans,getNum(getMerry(i)));
            }
            if (l < over) {
                ans = getNum(getMerry(i));
                over = l;
            }
        }
        REP(i,7) {
            cout << to_string(ans)[i] << " ";
        }
        cout << to_string(ans)[7];
    }
    return 0;
}