#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int p[8];

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

        max_n = -1;
        max_idx = -1;
        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 += min(c[j], p[j]);

            if (tmp > max_n) {
                max_idx = i;
                max_n = tmp;
            }
                
            rotate(c, c + 1, c + 8);
        }

        for (int i = 0; i < 7; i++)
            cout << c_print[(i + max_idx) % 8] << " ";
        cout << c_print[(7 + max_idx) % 8] << endl;
    }

    return 0;
}