#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  string mery = "12121414",ans;
  int k[8];
  for(int i = 0 ; i < 8 ; i++ )cin >> k[i];
  int mx = -1;
  for(int i = 0 ; i < 8 ; i++ ){
    rotate(mery.begin(),mery.begin()+i,mery.end());
    int t = 0;
    for(int j = 0 ; j < 8 ; j++ ){
      if((mery[j]-'0') < k[j])t+=mery[j]-'0';
      else t+=k[j]; 
    }
    if(mx < t ){
      mx = t;
      ans = mery;
    }
  }
  for(int i = 0 ; i < 8 ; i++ ){
    if(i == 0)cout << ans[i];
    else cout << " " << ans[i];
  }
  cout << endl;
}