#include<iostream>
using namespace std;

int main(){
  int p[8];
  int c[8],ans[8];
  int tmp,min;

  while(cin >> p[0]){
    for(int i=1;i<8;i++)cin >> p[i];
    c[0] = 1;
    c[1] = 2;
    c[2] = 1;
    c[3] = 2;
    c[4] = 1;
    c[5] = 4;
    c[6] = 1;
    c[7] = 4;

    min = -1;

    for(int i=0;i<8;i++){
      tmp = 0;
      for(int j=0;j<8;j++){
	if(p[j] > c[j])tmp += p[j] - c[j];
      }
      if(tmp < min || min < 0){
	min = tmp;
	for(int j=0;j<8;j++)ans[j] = c[j];
      }else if(tmp == min){
	bool f = false;
	for(int j=0;j<8;j++){
	  if(ans[j] > c[j]){
	    f = true;
	    break;
	  }else if(ans[j] < c[j])break;
	}
	if(f){
	  for(int j=0;j<8;j++)ans[j] = c[j];
	}
      }

      tmp = c[0];
      for(int i=1;i<8;i++)c[i-1] = c[i];
      c[7] = tmp;
    }
    for(int i=0;i<7;i++)cout << ans[i] << " ";
    cout << ans[7] << endl;
  }
}