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

const string uma = "41412121";
const int INF = 1e9;

int main() {
  vector<int> p(8);
  auto input = [&]() {
    for (int i = 0; i < 8; ++i) {
      if (cin >> p[i]) continue;
      return false;
    }
    return true;
  };
  while (input()) {
    int m = INF;
    string ans = uma;
    for (int i = 0; i < 8; ++i) {
      int s = 0;
      string c;
      for (int j = 0; j < 8; ++j) {
        c += uma[(i + j) % 8];
        s += max(0, p[j] - (uma[(i + j) % 8] - '0'));
      }
      if (s < m) {
        ans = c;
        m = s;
      } else if (s == m) {
        ans = (stoi(ans) < stoi (c)) ? ans : c;
      }
    }
    for (int i = 0; i < 8; ++i) cout << ( (i) ? " " : "" ) << ans[i];
    cout << endl;
  }
  return 0;
}

