#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    int a[8];
    int b[]={4,1,4,1,2,1,2,1};
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7]){
        int sum=9999, data=0;
        rep(i,8){
            int tmp = 0;
            rep(j,8){
                tmp += max(0,a[j]-b[(i+j)%8]);
            }
            if(tmp<sum){
                sum=tmp;
                data=0;
                rep(j,8){
                    data*=10;
                    data+=b[(i+j)%8];
                }
            }
            else if(tmp==sum){
                int t=0;
                rep(j,8){
                    t*=10;
                    t+=b[(i+j)%8];
                }
                if(data>t){
                    sum=tmp;
                    data=t;
                }

            }
        }
        int ans[8];
        rep(i,8){
            ans[i]=data%10;
            data/=10;
        }
        for(int i=7;i>=0;i--){
            if(i!=7)cout<<" ";
            cout<<ans[i];
        }
        cout<<endl;
    }
}