#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    vector<int> v = {1, 4, 1, 4, 1, 2, 1, 2 ,1, 4, 1, 4, 1, 2, 1, 2};
    
    vector<int> p(8);
    while(cin>>p[0]>>p[1]>>p[2]>>p[3]>>p[4]>>p[5]>>p[6]>>p[7]){
        int ansval = -1;
        vector<int> vec(8);
        rep(i,8){
            int tmpval = 0;
            vector<int> tmp(8);
            for(int j=i; j<i+8; j++){
                tmp[j-i] = v[j];
                tmpval += min(v[j],p[j-i]);
            }
            if(ansval<tmpval || (ansval==tmpval && tmp<vec )){
                ansval = tmpval;
                vec = tmp;
            }
        }
        
        rep(i,vec.size()){
            if(i)cout<<" ";
            cout<<vec[i];
        }
        cout<<endl;
    }
}

