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

int main(){
  int k[8];

  string mery = "12121414",ans;
  while(cin >> k[0] >> k[1] >> k[2] >> k[3] >> k[4] >> k[5] >> k[6] >> k[7]){
    int mn = 1000000000;
    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+=k[j]-(mery[j]-'0');
      }
      if(mn > t ){
	mn = t;
	ans = mery;
      }
    }
    for(int i = 0 ; i < 8 ; i++ ){
      if(i == 0)cout << ans[i];
      else cout << " " << ans[i];
    }
    cout << endl;
  }
  return 0;
}