#include<iostream>
 
using namespace std;
 
typedef long long ll;

const int start[] = {1,4,1,4,1,2,1,2};
int now[] = {1,4,1,4,1,2,1,2};
int ans[8];
int out;
int in[8];


bool isunder(){

  for(int i = 0; i < 8; i++){
    if(ans[i] < now[i]) return false;
    if(ans[i] > now[i]) return true;
  }
  return false;
}

void move(){

  int end = now[7];

  for(int i = 6; i >= 0; i--)
    now[i+1] = now[i];

  now[0] = end;
}

void check(){

  int sum = 0;

  for(int i = 0; i < 8; i++)
    sum += max(0,in[i]-now[i]);
  

  if(sum < out || (sum==out && isunder())){
    for(int i = 0; i < 8; i++)
      ans[i] = now[i];
    out = sum;
  }
}

bool fin(){
  for(int i = 0; i < 8; i++)
    if(now[i] != start[i]) return false;

  return true;
}
void solve(){

  while(1){
    check();
    move();
    if(fin()) break;
  }

  for(int i = 0; i < 8; i++){
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

void init(){
  ans[0] = -1;
  out = (1<<30);
}

bool input(){
  init();
  for(int i = 0; i < 8; i++)
    if(!(cin >> in[i])) return false;

  return true;
}
int main(){
  
  while(input()) solve();
  
  return 0;
}