#include <iostream>
#include <algorithm>

using namespace std;

const int ride[] = {1, 2, 1, 2, 1, 4, 1, 4};

int main()
{
    int p[8];

    while (cin >> p[0]) {
        for (int i = 1; i < 8; i++)
            cin >> p[i];

        int max_i = 0;
        int max_v = 0;
        for (int i = 0; i < 8; i++) {
            int tmp = 0;
            for (int j = 0; j < 8; j++) 
                tmp += min(p[j], ride[(i + j) % 8]);
            
            if (tmp > max_v) {
                max_i = i;
                max_v = tmp;
            }
        }
        for (int i = 0; i < 7; i++)
            cout << ride[(i + max_i) % 8] << " ";
        cout << ride[(7 + max_i) % 8] << endl;
    }

    return 0;
}