#include <iostream>
using namespace std;

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

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;
  for(int j=1;j<8;j++) {
    for(int i=0;i<8;i++) {
      c[j][i] = c[0][(i-j+8)%8];
    }
  }
}

int main() {
  cswap();
  int p[8],top=1000000,pos;

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

    for(int i=0;i<8;i++) {
      if(i!=7)
        cout << c[pos][i] << " ";
      else
        cout << c[pos][i] << endl;

    }

  }
}