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

typedef pair<int, int> Pair;
#define INF 0x7fffffff

int d[] = {4, 1, 4, 1, 2, 1, 2, 1};
int ps[100];

int main() {
  while (1) {
    for (int i=0; i<8; i++) {
      if (scanf("%d", &ps[i]) != 1) return 0;
    } 

    int mod = 1;
    Pair ans(INF, INF);
    for (int i=0; i<8; i++) {
      int sum = 0;
      int encoded = 0;

      for (int j=0; j<8; j++) {
        sum += max(ps[j]-d[(i+j)%8], 0);
        encoded = encoded*10 + d[(i+j)%8];
      }

      ans = min(ans, Pair(sum, encoded));
      mod *= 10;
    }

    int t = ans.second;
    mod /= 10;
    printf("%d", t/mod);
    t %= mod;
    for (int i=1; i<8; i++) {
      mod /= 10;
      printf(" %d", t/mod);
      t %= mod;
    }
  }
}