#include <iostream>
#include <sstream>
using namespace std;
int c[8][9] = {};
void cswap() {
  c[0][0] = 4;c[0][1] = 1;c[0][2] = 4;c[0][3] = 1;
  c[0][4] = 2;c[0][5] = 1;c[0][6] = 2;c[0][7] = 1;c[0][8] = 0;
  for(int j=1;j<8;j++) {
    for(int i=0;i<8;i++) {
      c[j][i] = c[0][(j+i+8)%8];
    }
  }
  stringstream ss;
  for(int j=0;j<8;j++) {
    for(int i=0;i<8;i++) {
      ss << c[j][i];
    }
    ss >> c[j][8];
    ss.str("");
    ss.clear(stringstream::goodbit);
  }
}

int main() {
  cswap();
  int p[8],num;
  while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
    int sum[8] = {},pos = 0;
    for(int j=0;j<8;j++) {
      for(int i=0;i<8;i++) {
        sum[j] += max(p[i]-c[j][i],0);
      }
    }
    int top = sum[0];
    for(int j=1;j<8;j++) {
      if(sum[j] < top) {
        top = sum[j];
        pos = j;
        num = c[j][8];
      }
    }

    for(int j=0;j<8;j++) {
      if(sum[j] == top && c[j][8] < num) {
        pos = j;
        num = c[j][8];
      }
    }
    int check=0;
    for(int i=0;i<8;i++) {
      if(check) cout << " ";
      cout << c[pos][i];
      check++;
    }
    cout << endl;
  }
}