#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
using namespace std;


int p[8];
int m[] = {4, 1, 4, 1, 2, 1, 2, 1, 4, 1, 4, 1, 2, 1, 2, 1};

int to_i(string s) {
    istringstream is(s);
    int n; is >> n;
    return n;
}

int hash(int index) {
    string s;
    for (int i = index; i < index+8; i++) 
        s.push_back(m[i] + '0');
    return to_i(s);
}

string to_s(int n) {
    ostringstream os;
    os << n;
    return os.str();
}

string format(int n) {
    string s = to_s(n);
    string t;
    t.push_back(s[0]);
    for (int i = 1; i < 8; i++) {
        t.push_back(' ');
        t.push_back(s[i]);
    }
    return t;
}

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

        int min_wait = INF;
        int min_hash = INF;
        for (int i = 0; i < 8; i++) {
            int wait = 0;
            for (int j = 0; j < 8; j++) {
                if (m[i+j] < p[j]) {
                    wait += (p[j] - m[i+j]);
                }
            }
            if (min_wait > wait) {
                min_wait = wait;
                min_hash = hash(i);
            }
        }

        cout << format(min_hash) << endl;
    }
    return 0;
}