#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int tmp[8][8]={
    {1,2,1,2,1,4,1,4},
    {1,2,1,4,1,4,1,2},
    {1,4,1,2,1,2,1,4},
    {1,4,1,4,1,2,1,2},
    {2,1,2,1,4,1,4,1},
    {2,1,4,1,4,1,2,1},
    {4,1,2,1,2,1,4,1},
    {4,1,4,1,2,1,2,1},
  };
  int in[8];
  while(cin>>in[0]){
    rep(i,7)cin>>in[i+1];
    int ans=0;
    int ans1;  
    rep(i,8){
      int co=0;
      rep(j,8)
	if(tmp[i][j]<=in[j])co+=tmp[i][j];
	else co+=in[j];
      if(ans<co){ans1=i;ans=co;}
    }
    rep(i,7)cout<<tmp[ans1][i]<<" ";
    cout<<tmp[ans1][7]<<endl;
  }
}