#include <iostream>
#include <vector>
using namespace std;

int main(){
    int cap[8] = {1, 4, 1, 4, 1, 2, 1, 2}, p[8];
    while( cin >> p[0] ){
        for(int i = 1; i < 8; i++) cin >> p[i];
        int minv = 10000000;
        vector<int> mem;
        for(int i = 0; i < 8; i++){
            int ms = 0;
            vector<int> tmp;
            for(int j = 0; j < 8; j++){
                ms += (p[j] - cap[(j+i)%8]) < 0 ? 0 : (p[j]-cap[(j+i)%8]);
                tmp.push_back( cap[(j+i)%8] );
            }
            if( ms < minv ){
                minv = ms;
                mem = tmp;
            }else if( ms == minv && tmp < mem ){
                mem = tmp;
            }
        }
        vector<int>::iterator it = mem.begin();
        cout << *it;
        while( (++it) != mem.end() ) cout << ' ' << *it;
        cout << endl;
    }
    return 0;
}