#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define f first
#define s second

int fj[8][8] = {4, 1, 4, 1, 2, 1, 2, 1};

int main(){
  for(int i = 1 ; i < 8 ; i++){
    for(int j = 0 ; j < 8 ; j++){
      int t = j+1;
      if(t == 8) t = 0;
      fj[i][j] = fj[i-1][t];
    }
  }
  
  int p[8], tmp[8];
  int Count[8];
  while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
    for(int i = 0 ; i < 8 ; i++){
      for(int j = 0 ; j < 8 ; j++) tmp[j] = p[j];
      int cnt = 0;
      bool flag = false;
      for(int j = 0 ; j < 8 ; j++){
	tmp[j] -= fj[i][j];
	tmp[j] = max(0, tmp[j]);
	cnt += tmp[j];
      }
      Count[i] = cnt;
    }
    
    pair<int, string> check[8];
    for(int i = 0 ; i < 8 ; i++){
      string tmp = "";
      for(int j = 0 ; j < 8 ; j++){
	tmp += fj[i][j]+'0';
      }
      check[i].f = Count[i];
      check[i].s = tmp;
    }
    sort(check, check+8);
    /*
    for(int i = 0 ; i < 8 ; i++){
      cout << "cnt = " << check[i].f << ", V = " << check[i].s << endl;
    }*/
    
    for(int i = 0 ; i < 8 ; i++){
      if(i != 7) cout <<check[0].s[i] << ' ';
      else cout << check[0].s[i] << endl;
    }
  }
  return 0;
}