#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
using namespace std;
#define INF 70000000
typedef pair < int , int > P;
int toint(int* n){
  return n[0] * 1000000 + n[1] * 100000 + n[2] * 100000 +
    n[3] * 10000 + n[4] * 1000 + n[5] * 100 + n[6] * 10 + n[7];
}
int main(){
  int p[8], sum, num, ret[8];
  while(~scanf("%d %d %d %d %d %d %d %d",p,p+1,p+2,p+3,p+4,p+5,p+6,p+7)){

    sum = 0;
    num = INF;

    int man[] = { 4, 1, 4, 1, 2, 1, 2, 1 };
    for(int i = 0 ; i < 8 ; i++ ){
      rotate( man, man + 7, man + 8);

      int res = 0;
      for(int j = 0 ; j < 8 ; j++ ){
        res += min( man[j], p[j]);
      }

      if( res > sum ){ // resの方が大きかったらHappy
        num = toint(man);
        memcpy( ret, man, sizeof man);
        sum = res;
      } else if( res == sum ){ // 小さい方
        if(num > toint(man)){
          num = min( num, toint(man));
          memcpy( ret, man, sizeof man);
        }
      }
    }
    for(int i = 0 ; i < 8 ; i++ ){
      cout << ( i ? " " : "" ) << ret[i];
    }
    cout << endl;
  }
}