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

int main()
{
    int p[8];
    while(cin >> p[0]){
        for(int i = 1; i < 8; ++i) cin >> p[i];
        int q[8] = {4,1,2,1,2,1,4,1};
        int min_ = 1 << 26;
        int ans[8];
        for(int i = 0; i < 8; ++i){
            int temp = 0;
            for(int j = 0; j < 8; ++j){
                temp += (p[j] - q[j] > 0 ? p[j] - q[j] : 0); 
            }
            
            if(min_ > temp){
                min_ = temp;
                for(int j = 0; j < 8; ++j){
                    ans[j] = q[j];
                }
            } else if(min_ == temp) {
                stringstream ss, tt;
                for(int j = 0; j < 8; ++j){
                    ss << ans[j];
                    tt << q[j];
                }
                int s, t;
                ss >> s;
                tt >> t;
                if(s > t){
                    for(int j = 0; j < 8; ++j){
                        ans[j] = q[j];
                    }
                }
            }
            
            rotate(q, q + 1, q + 8);
        }
        
        for(int i = 0; i < 8; ++i){
            if(i) cout << ' ';
            cout << ans[i];
        }
        cout << endl;
    }
}