#include <cstdio>
#include <climits>
#include <algorithm>
using namespace std;

int main() {
  int i, j, k, s, t, u;
  int l[8];
  int m[8] = {4, 1, 4, 1, 2, 1, 2, 1};
  int o[8] = {0, 2, 6, 4, 3, 5, 1, 7};

  while (1) {
    for (i=0; i<8; i++) {
      s = scanf("%d", &l[i]);
    }
    if (s!=1) break;
    t = 0;
    for (i=0; i<8; i++) {
      s = 0;
      for (j=0, k=o[i]; j<8; j++, k++, k%=8) {
        s += min(l[j], m[k]);
      }
      if (s >= t) {
        t = s;
        u = i;
      }
    }
    printf("%d", m[o[u]]);
    for (i=1, j=(o[u]+1)%8; i<8; i++, j++, j%=8) {
      printf(" %d", m[j]);
    }
    printf("\n");
  }

  return 0;
}