#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<cstdio>
using namespace std;
int v[] = {4,1,4,1,2,1,2,1};

string itos(int p)
{
  stringstream ss;
  for(int i=p;i<8+p;i++)
    ss << v[i%8];
  return ss.str();
}

int main()
{
  vector<int> p;
  p.resize(8);
  while(scanf("%d %d %d %d %d %d %d %d",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6],&p[7]) != EOF)
    {
      vector<string> ans;
      int mincost = (1<<29),minpos = -1;
      for(int i=0;i<8;i++)
	{
	  int cost = 0;
	  for(int j=0;j<8;j++)
	    cost += (p[j]-v[(i+j)%8]<=0)? 0:(p[j]-v[(i+j)%8]);
	  if(mincost == cost)
	    {
	      ans.push_back(itos(i));
	    }
	  else if(mincost > cost)
	    {
	      mincost = cost;
	      ans.clear();
	      ans.push_back(itos(i));
	    
	    }
	}
      
      if(ans.size() > 1)
	sort(ans.begin(),ans.end());
      for(int i=0;i<8;i++)
	{
	  cout << ans[0][i];
	  i==7?cout << endl:cout << " ";
	}
    }
  return 0;
}