#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int main(){
    while(1){
        array<int,8> a;
        rep(i,8) cin>>a[i];
        if(!cin) break;
        int g=1<<30;
        array<int,8> capa = {1,4,1,4,1,2,1,2}, ans;
        rep(i,8){
            rotate(capa.begin(), capa.begin()+1, capa.end());
            int min=0;
            rep(j,8) min+=max(0,a[j]-capa[j]);
            if(min<g||(min==g&&lexicographical_compare(all(capa),all(ans)))){
                ans=capa;
                g=min;
            }
        }
        rep(i,8) cout<<ans[i]<<((i==7)?'\n':' ');
    }
}