#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<cstdlib>
#include<deque>
using namespace std;
int Jenny[8]={4,1,4,1,2,1,2,1};
vector<int>keys;
vector<int>value;
void t_sort(){
  for(int y=0;y<keys.size()-1;y++){
    for(int x=0;x<keys.size()-1;x++){
      if(value[x]>=value[x+1]){
	if(value[x]==value[x+1]){
	  if(keys[x]>keys[x+1]){
	    int t=keys[x]; keys[x]=keys[x+1]; keys[x+1]=t;
	  }
	}
	else{
	  int t=value[x]; value[x]=value[x+1]; value[x+1]=t;
	  int tk=keys[x]; keys[x]=keys[x+1]; keys[x+1]=tk;
	}
      }
    }
  }
}
string IntToString(int t){
  char cc[100];
  sprintf(cc,"%d",t);
  string ret=cc;
  return ret;
}
int main(){
  int p[8];
  while(cin>>p[0]>>p[1]>>p[2]>>p[3]>>p[4]>>p[5]>>p[6]>>p[7]){
    keys.clear(); value.clear();
    for(int i=0;i<8;i++){
      string tmp="";
      int cost=0;
      for(int x=0;x<8;x++){
	int j_p=x+i>7?(x+i)-8:x+i;
	int t=p[x]-Jenny[j_p];
	tmp+=IntToString(Jenny[j_p]);
	cost+=(t>0?t:0);
      }
      keys.push_back(atoi(tmp.c_str()));
      value.push_back(cost);
    }
    t_sort();
    // for(int x=0;x<keys.size();x++)
    //   cout<<keys[x]<<" "<<value[x]<<endl;
    string res=IntToString(keys[0]);
    for(int x=0;x<res.size();x++){
      cout<<res[x];
      if(x==res.size()-1) cout<<endl;
      else cout<<" ";
    }
  }
}