#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int t[9];
int merry[3] = {1,2,4};

int main(){
  t[0] = 1;
  REPR(i,9)t[i]=t[i-1]*3;
  int _p;
  while(~scanf("%d",&_p)){
    int p[8];
    p[0] = _p;
    REPR(i,8)cin>>p[i];
    int _[8] = {1,2,1,2,1,4,1,4};
    vi merry(_,_+8);
    string merrystr = "12121414";
    int minscore = 1145141919;
    string minid = "999999999";
    vi ret;
    REP(i,8){
      // calc
      int score = 0;
      REP(j,8) score += max(0,p[j]-merry[j]);
      if(score < minscore){
        minid = merrystr;
        ret = merry;
        minscore = score;
      }else if(score==minscore && merrystr < minid){
        minid = merrystr;
        ret = merry;
        minscore = score;
      }
      // loop
      int head = merry[0]; merry.erase(merry.begin()); merry.push_back(head);
      merrystr = merrystr.substr(1) + merrystr[0];
    }
    cout<<ret[0];
    REPR(i,8)cout<<" "<<ret[i];
    cout<<endl;
  }
  return 0;
}