#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9;
vector<int> p(8), a(8);

template <typename T> string tostr(const T& t) {
    ostringstream os; os<<t; return os.str();
}

void shift(vector<int>& a) {
    int sz = a.size();
    for (int i = sz - 1; i > 0; i--)
        swap(a[i], a[i - 1]);
}

int main() {
    for (int i = 0; i < 8; i++) {
        if (i % 2) a[i] = 1;
        else if (i <= 2) a[i] = 4;
        else a[i] = 2;
    }

    while (scanf("%d", &p[0]) != EOF) {
        for (int i = 1; i < 8; i++)
            scanf("%d", &p[i]);
        
        int min = INF;
        vector<int> ans(8);
        for (int i = 0; i < 8; i++) {
            shift(a);

            int sum = 0;
            for (int j = 0; j < 8; j++) {
                sum += max(p[j] - a[j], 0);
            }

            if (sum < min) ans = a, min = sum;
            else if (sum == min) {
                string ss = "", sa = "";
                for (int k = 0; k < 8; k++) {
                    ss += tostr(a[k]);
                    sa += tostr(ans[k]);
                }
                if (ss < sa) ans = a, min = sum;
            }
        }

        for (int i = 0; i < 8; i++) {
            if (i) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }

    return 0;
}
