#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int p[8], num[8] = {1, 2, 1, 2, 1, 4, 1, 4};
  while (cin >> p[0]) {
    for (int i = 1; i < 8; i++) {
      cin >> p[i];
    }
    int ans = -1, d_min = 1 << 30;
    for (int i = 0; i < 8; i++) {
      int d = 0;
      for (int j = 0; j < 8; j++) {
        d += max(0, p[j] - num[(i + j) % 8]);
      }
      if (d < d_min) d_min = d, ans = i;
      else if (d == d_min) {
        for (int j = 0; j < 8; j++) {
          int l = (i + j) % 8, r = (ans + j) % 8;
          if (num[l] == num[r]) continue;
          if (num[l] < num[r]) ans = i;
          break;
        }
      }
    }
    for (int i = 0; i < 8; i++) {
      cout << num[(i + ans) % 8] << " \n"[i + 1 == 8];
    }
  }

  return 0;
}
