#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,n[8],ans[8],p[8] = {1,4,1,4,1,2,1,2};
  int min,best;
  while(cin >> n[0]){
    for(i=1;i<8;i++) cin >> n[i];

    for(i=0;i<8;i++){
      ans[i] = 0;
      for(j=0;j<8;j++){
	if(n[j] - p[(j+i)%8] > 0) ans[i] += n[j] - p[(j+i)%8];
      }
    }

    min = ans[0];
    best = 0;
    for(i=1;i<8;i++){
      if(min > ans[i]){
	min = ans[i];
	best = i;
      }
    }

    for(i=0;i<7;i++) cout << p[(best+i)%8] << " ";
    cout << p[(best+7)%8]<< endl;

  }
  return 0;
}