#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1010

const int c[8] = { 1,2,1,2,1,4,1,4 };

int hash(int i){
  int ret = 0;
  REP(j,8){
    int now = (i+j)%8;
    ret *= 10;
    ret += c[now];
  }
  return ret;
}

int main(){
  int p[8];
  while(cin>>p[0]){
    int ansIdx;
    int ansmax = 0;
    int anshsh;
    REP(i,7) cin>>p[i+1];
    REP(i,8){
      int sum = 0;
      REP(j,8){
	int now = (i+j)%8;
	sum += min(p[j], c[now]);
      }
      if(ansmax <= sum){
	if(ansmax == sum){
	  int tmp = hash(i);
	  if(anshsh > tmp){
	    anshsh = tmp;
	    ansIdx = i;
	  }
	}else{
	  ansIdx = i;
	  ansmax = sum;
	  anshsh = hash(i);
	}
      }
    }
    REP(j,8){
      int now = (ansIdx+j)%8;
      printf("%d%c",c[now],(j==7?'\n':' '));
    }
  }
  return 0;
}