#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int p[8];

    while (cin >> p[0]) {
        int min_n, min_idx;
        int c[8] = {1, 2, 1, 2, 1, 4, 1, 4};
        int c_print[8] = {1, 2, 1, 2, 1, 4, 1, 4};

        min_n = 100000;
        min_idx = 0;
        for (int i = 1; i < 8; i++)
            cin >> p[i];

        for (int i = 0; i < 8; i++) {
            int tmp = 0;
            for (int j  = 0; j < 8; j++)
                tmp += p[j] - min(c[j], p[j]);

            if (tmp < min_n) {
                min_idx = i;
                min_n = tmp;
            }
                
            rotate(c, c + 1, c + 8);
        }
        for (int i = 0; i < 7; i++)
            cout << c_print[(i + min_idx) % 8] << " ";
        cout << c_print[(7 + min_idx) % 8] << endl;
    }

    return 0;
}