#include <bits/stdc++.h>
using namespace std;

int main() {
  int p[8], a[] = {4, 1, 4, 1, 2, 1, 2, 1};
  vector<int> v{3, 5, 1, 7, 4, 6, 2, 0};
  while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
    int maxs = 0;
    int idx = 0;

    for (auto i : v) {
      int cnt = 0;
      for (int j = 0; j < 8; ++j) {
        cnt += min(p[j], a[(i + j) % 8]);
      }

      if (maxs < cnt) {
        idx = i;
        maxs = cnt;
      }
    }

    for (int i = 0; i < 8; ++i) {
      cout << a[(i + idx) % 8] << (i + 1 == 8 ? "\n" : " ");
    }
  }
}