#include<bits/stdc++.h>
using namespace std;
#define INF 10000000

int main(){
  int com[]={4,1,4,1,2,1,2,1};
  int c[8]={0};
  while(cin >> c[0]){
    for(int i=1;i<8;i++){
      cin >> c[i];
    }
    int nmin = INF;
    int pos = 0;
    int mmin = 0;
    for(int i=0;i<8;i++){
      int sum = 0;
      for(int j=0;j<8;j++){
	sum += max(0,c[j] - com[(i+j)%8]);
      }
      int tmp = 0;
      int cou = 7;
      for(int z=0;z<8;z++){
	tmp += com[(i+z)%8] * (int)pow(10,(double)cou);
	cou--;
      }
      if(nmin > sum || (nmin == sum && tmp < mmin)){
	pos = i;
	nmin = sum;
	int cou = 7;
	mmin = 0;
	for(int z=0;z<8;z++){
	  mmin += com[(i+z)%8] * (int)pow(10,(double)cou);
	  cou--;
	}
      }
    }
    bool flg=false;
    for(int i=0;i<8;i++){
      if(flg) cout << " ";
      cout << com[(pos+i)%8];
      flg = true;
    }
    cout << endl;
  } 
}