#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;

void cycle(vector<int> &v) {
    vector<int> ret(v.begin() + 1, v.end());
    ret.push_back(v[0]);
    v = ret;
}

int main() {
    vector<int> gowland = {1,4,1,4,1,2,1,2};
    vector<int> p(8);
    while (cin >> p[0]) {
        for (int i=1; i<8; ++i) {
            cin >> p[i];
        }
        vector<int> ans;
        int mn = INT_MAX;
        for (int k=0; k<8; ++k) {
            int cnt = 0;
            for (int i=0; i<8; ++i) {
                cnt += max(0, p[i] - gowland[i]);
            }
            if (cnt < mn || (cnt == mn && gowland < ans)) {
                ans = gowland;
                mn = cnt;
            }
            cycle(gowland);
        }
        for (int i=0; i<(int)ans.size(); ++i) {
            cout << (i == 0 ? "" : " ") << ans[i];
        }
        cout << endl;
    }
    return 0;
}