#include <iostream>
#include <algorithm>

using namespace std;

int ret_num(int c[8])
{
    int ret = 0;
    for (int i = 0; i < 8; i++) {
        ret *= 10;
        ret += c[i];
    }
    return ret;
}

int main()
{
    int p[8];

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

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

        for (int i = 0; i < 8; i++) {
            int tmp = 0;
            int c_tmp = ret_num(c);

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

            if (tmp < min_n || (tmp == min_n && min_rot < c_tmp)) {
                min_idx = i;
                min_n = tmp;
                min_rot = c_tmp;
            }
                
            rotate(c, c + 1, c + 8);
        }

        for (int i = 0; i < 8; i++)
            cout << c_print[(i + min_idx) % 8] << (i == 7 ? '\n' : ' ');
    }

    return 0;
}